ITextSharp cannot convert all HTML to PDF

Using the code examples from here , I come up with these codes -

var my_html = this.GetmyReportHtml(); var my_css = this.GetmyReportHtmlCss(); Byte[] bytes; using (var ms = new MemoryStream()) { using (var doc = new iTextSharp.text.Document(PageSize.LETTER)) { using (var writer = PdfWriter.GetInstance(doc, ms)) { doc.Open(); try { using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(my_css))) { using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(my_html))) { iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msHtml, msCss); } } } catch (Exception ex) { } finally { doc.Close(); } } } bytes = ms.ToArray(); } System.IO.File.WriteAllBytes(@"c:\\temp\test.pdf", bytes); 

PDF was created. However my_html has 6 pages in my case, only half of the content is converted to pdf.

Does anyone know what happened here? How to find out if iTextSharp.tool.xml.XMLWorkerHelper.GetInstance () works. Does ParseXHtml work correctly?

thank

0
html c # pdf itextsharp
Mar 08
source share
1 answer

Problem detected. In this line of codes -

 using (var doc = new iTextSharp.text.Document(PageSize.LETTER)) 

PageSize.LETTER could not be passed.

0
Mar 08 '15 at 4:52
source share



All Articles