itextsharp generating PDF into client browser: (Vb.net)
I'm currently trying to make itextsharp generating PDF file into the browser using .NET framework.. and yes, I'm using VB.net instead of C# here...
开发者_如何学JAVAI already compiled everything and it's no error. What makes the browser didn't send me the pdf result? I wonder if i forgotten something?
Source Code:
Private Sub createPDF()
Using ms As New MemoryStream()
Dim document As New Document(PageSize.A4, 25, 25, 30, 30)
Dim writer As PdfWriter = PdfWriter.GetInstance(document, ms)
document.Open()
document.Add(New Paragraph("Hello World"))
document.Close()
writer.Close()
Response.ContentType = "pdf/application"
Response.AddHeader("content-disposition", "attachment;filename=First PDF document.pdf")
Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length)
End Using
End Sub
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "inline; filename=FileName.pdf");
If you want it to display the PDF in the browser you may want to use inline instead of attachment. Otherwise it will only offer the PDF as a file download.
Response.ContentType = "pdf/application"
I think you have that backwards. Should be application/pdf
精彩评论