I'm currently trying to do itextsharp to create a PDF file in a browser using the .NET framework .. and yes, I use VB.net instead of C # here ...
I already compiled everything, and this is not a mistake. What causes the browser not to send me the result in pdf format? Interestingly, I forgot something?
Source:
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
source
share