> Date: Mon, 4 Apr 2011 13:51:57 -0500 > From: digitron...@cwpanama.net > To: itext-questions@lists.sourceforge.net > Subject: [iText-questions] Error opening pdf document > > I am using itextshap version 5.0.4.0 to generate a pdf file, to print > an output of some data generated by an aspx page > In a sumary way, the page have two textboxes and a button > I fill some data in textboxes and then click the button to get the > output in a pdf window > Inside the button click event I have this code > > Response.ContentType = "application/pdf" > Response.AddHeader("Content-Disposition", "attachment; filename=itext.pdf") > Dim doc1 As New Document() > PdfWriter.GetInstance(doc1, Response.OutputStream) > doc1.Open() > doc1.Add( > New Paragraph(TextBox1.Text)) > doc1.Add( > New Paragraph(TextBox2.Text)) > doc1.Close()
your problem is completely unrelated to iTextSharp. unless you explicitly call Response.End(), the .aspx page will append HTML to the stream. try this test: [1] instead of opening the PDF save it to disk. [2] open the PDF with a text editor you'll see the HTML of your .aspx page. it **shouldn't** be there. in most cases you should be using a HTTP Handler to send PDF anyway: http://msdn.microsoft.com/en-us/library/system.web.ihttphandler.aspx lower overhead than a .aspx page ------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php