I just added the nuget XMLWorker iTextSharp package (and its dependencies) to my project, and I'm trying to convert HTML from a string to a PDF file, even though no exceptions are thrown, the PDF file is generated by two blank pages. Why?
In the previous version of the code, only iTextSharp 5.5.8.0 was used using the HTMLWorker and ParseList methods, then I switched to
Here is the code I'm using:
public void ExportToPdf() { string htmlString = ""; Document document = new Document(PageSize.A4, 40, 40, 40, 40); var memoryStream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, memoryStream); document.Open(); htmlString = sbBodyMail.ToString(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, new StringReader(htmlString)); document.Close(); DownloadFile(memoryStream); } public void DownloadFile(MemoryStream memoryStream) {
If I put document.Add(new Paragraph("Just a test")); right before document.Close(); , the paragraph appears on the second page, but the rest of the document is still empty.
UPDATE
I changed the HTML in the htmlString variable htmlString only DIV and TABLE , and it worked. So now the question is: how do I know which part of the HTML is causing some error in XMLWorker?
source share