Chapter 5: Custom tag workers and CSS appliers

In this chapter, we'll change two of the most important internal mechanisms of the pdfHTML add-on.

  • We'll override the default functionality that matches HTML tags with iText objects, more specifically the DefaultTagWorkerFactory mechanism, and

  • We'll override the default functionality that matches CSS styles to iText styles, more specifically the DefaultCssApplierFactory mechanism.


iText 7: Converting HTML to PDF with pdfHTML

In this tutorial, we'll learn how to convert HTML to PDF using pdfHTML, an add-on to iText 7. If you're new to iText, please jump to chapter 1 immediately. If you've been working with iText in the past, you might remember the old HTML to PDF functionality. If that's the case, you've either been using the HTMLWorker class (iText 2), or the XML Worker add-on (iText 5).

Introduction iText 7's new add-on pdfHTML is a tool that aims to greatly simplify HTML to PDF conversion in Java or .NET. This is a straightforward and uniform use case, so many users will get satisfactory results with the one-line code sample below. For more complex usage, you may need to provide some configuration to pdfHTML. In this post, I will attempt to explain why you may need to use the config options, and how to use them. Basics The default way to use pdfHTML is either one of two basic one-line code samples: HtmlConverter.convertToPdf(new File("input.html"), new...
iText Launches pdfHTML to Easily Convert HTML to PDF Ghent, Belgium, March 16, 2017 – Leading PDF library company iText Software today introduced pdfHTML, a powerful tool to easily convert HTML and CSS content into a PDF document. An iText 7 add-on, pdfHTML is a premium upgrade to the previous XML Worker from iText 5. The new solution provides more functionality out of the box and easier extensibility and customization. “HTML is ubiquitous. A lot of software already outputs HTML in one way or another, and most developers know at least the basics,” said Raf Hens, iText director of product...

iText 7 converting HTML to PDF

Use the pdfHTML add-on to convert HTML and CSS to PDF.