Hi, Using the last iTextSharp library (5.0.2), I have an issue and didn’t find on the web how to manage with this.
What I want to do : - Create a pdf based on HTML - Sign the pdf The objective would be to create the whole .pdf before having to write it on the hard disk. When I’m trying to use my “Stream” to create a new PdfReader, I get the following error : An unhandled exception of type 'iTextSharp.text.exceptions.InvalidPdfException' occurred in itextsharp.dll Additional information: PDF header signature not found. My code : ------------------------------------------ Document doc = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream( Environment.CurrentDirectory + "\\testPdfCreation.pdf", FileMode.Create)); doc.Open(); string strURL = Environment.CurrentDirectory + "\\test.html"; Uri uri = new Uri(strURL); FileWebRequest req = (FileWebRequest)WebRequest.Create(uri); WebResponse resp = req.GetResponse(); Stream stream = resp.GetResponseStream(); StreamReader sr = new StreamReader(stream); string html = sr.ReadToEnd(); List<iTextSharp.text.IElement> lt = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(html), null); ColumnText ct = new ColumnText(writer.DirectContent); ct.SetSimpleColumn(50, 50, PageSize.A4.Width - 50, PageSize.A4.Height - 50); for (int k = 0; k < lt.Count; ++k) ct.AddElement((IElement)lt[k]); ct.Go(); doc.Close(); //-------------------- //!\ ERROR PdfReader reader = new PdfReader(stream); //Same error: PdfReader reader = new PdfReader(sr.BaseStream) //-------------------- (…) ------------------------------------------ I tried many things but no evolution… I read on the net that we have to close the document before being able to create a Pdfreader, but nothing works for the moment. Thanks in advance if you could help me. Best regards, leparachute.
------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/