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
Don Mar 08 2018-11-15T00: 00Z
source share