1

I am using iTextSharp to create a document in PDF format.

Some paragraphs are in XHTML format (for instance, header and footer of document).

Those XHTML contain IMG tags so when document is created, images are not rendered, of course.

How can I process those IMG tags to embed images correctly? I tried by creating a custom image tag processor but it seems it only works when converting a whole HTML to PDF.

I was looking in Internet but I have only found examples using xmlParser.Parse to process all HTML document. In my case, I need to use XMLWorkerHelper.ParseToElementList to add header and footer paragraphs.

Regards

jstuardo
  • 3,901
  • 14
  • 61
  • 136
  • I'm losing count as to how many times I've already had to repeat this. Look for questions tagged iText and read my comments to get an idea. Here we go again: we abandoned the name **iTextSharp** 2 years ago in favor of the name **iText for .NET**. iText 5 and XML Worker are no longer supported and have been replaced by iText 7 and the pdfHTML add-on. Please upgrade, and you'll notice that pdfHTML has better HTML and CSS support, requiring much less code. – Bruno Lowagie Aug 02 '18 at 14:41
  • Parsing HTML to a list of iText elements is explained in [chapter 1](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml/chapter-1-hello-html-pdf) of the [HTML to PDF tutorial](https://developers.itextpdf.com/content/itext-7-converting-html-pdf-pdfhtml/) that has been made available on the official website. The examples are in Java, but can easily be converted to C# because all the Java methods explained in the tutorial also exist in the .NET version of iText. You just need to change some lowercase characters into uppercase characters. – Bruno Lowagie Aug 02 '18 at 14:43
  • I cannot install iText7 using Nuget in Visual Studio 2012... the only version I could install is iTextSharp 5.5.13... that is why I need to know how to do it using ParseToElementList method – jstuardo Aug 02 '18 at 14:58
  • iTextSharp 5.5.13 is a *maintenance* release of the old iText version. iText 5 has been discontinued, but we occasionally make releases to help out paying customers. No new development is done on iText 5; those releases only contain bug fixes. **You can install iText7 using Nuget** *if you follow the instructions provided on the official web site*: https://developers.itextpdf.com/itext7/download-and-install-information/NET See https://www.nuget.org/packages/itext7/ – Bruno Lowagie Aug 02 '18 at 15:13
  • Thanks @BrunoLowagie... I could install iText7.... I will try that tutorial. – jstuardo Aug 07 '18 at 23:30

0 Answers0