I'm using VB.NET, Framwork 4.5. Visual Studio 2013.
I'm using itextsharp version 5.5.3.0
I'm able to generate correctly a PDF file using memorystream
via an aspx page when I pass querystring values and I open the page directly.
However when I try to open that same page in IE9 (sorry, stuck on that in our Enterprise and absolutely cannot change that) via showmodaldialog
, the pdf is not showing the "Open" or "Save As.." Dialog, it's just showing a blank page and nothing happens.
Can someone please tell me if there's a catch when using itextsharp when using IE9 and showmodaldialog
?
I had to use a hidden iframe
and javascript function to load the page in the iframe
so it shows the "Open Save as..." dialog in the same window.
It's working with iframe
but i'm curious of what is going on with showmodaldialog
Here's the master page code to send the querystring parameters to a modaldialog
case 'report':
mypage = 'pdfreport.aspx?mode=Individual&loteid=' + $('#IDLabel').text() + '&idah=' + param + '&invid=' + $('#hdfInventoryID').val()
//alert(mypage)
var width = '1000'
var height = '685'
var left = '20'
var top = '0'
break;
}
//alert(mypage)
var r = window.showModalDialog(mypage, 'mywindow', 'left:'+left+';top:'+top+';dialogWidth:' + width + 'px;dialogHeight:' + height + 'px;toolbar:0;resizable:0');
And here's the showmodaldialog code to generate the pdf:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim document As Document = New Document
Dim output2 As MemoryStream = New MemoryStream()
Dim writer As PdfWriter = PdfWriter.GetInstance(document, output2)
document.SetPageSize(PageSize.LETTER)
document.SetMargins(50, 50, 25, 25)
document.Open()
''code to generate the pdf document
document.Close()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Dim filename As String
filename = "Filename"
Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}.pdf", filename))
Response.BinaryWrite(output2.ToArray())
End Sub