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.


Chapter 4: Creating reports using pdfHTML

Roughly speaking, there are three major ways to create PDF documents using iText,

  1. You can create a PDF document from scratch using iText objects such as Paragraph, Table, Cell, List,... The advantage of this approach is that everything is programmable, hence configurable just the way you want it. The disadvantage is that you need to program everything; even small changes such as changing one color into another, require a developer to change the Java code of the application, to recompile the code, etc.


Chapter 3: Generating PDF based on Media Queries

In chapter 1, we converted the same hello.html page to different PDF document that looked (almost) identical, using different snippets of Java code. In this chapter, we'll convert one and the same HTML file to different PDF files with a different layout.


Chapter 2: Defining styles with CSS

In the previous chapter, we looked at different snippets of Java code. In this chapter, we'll use the same snippet for every example:

public void createPdf(String src, String dest) throws IOException {
    HtmlConverter.convertToPdf(new File(src), new File(dest));

Instead of looking at different snippets of Java code, we'll be looking at different snippets of HTML and CSS.


Chapter 1: Hello HTML to PDF

In this chapter, we'll convert some simple HTML snippets consisting of a "Test" header, a "Hello World" paragraph, and an image representing the iText logo, to PDF in many different ways.


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).

Last week, iText Software and Inbatek were invited by the Electronic Transactions Development Agency (ETDA) in Bangkok (Thailand) for a full day of talks and sessions about PDF and e-invoicing. ETDA is a Public Organization in Thailand that functions as the main agency responsible for developing, promoting and supporting electronic transactions in order to create trust, opportunity and equity for all. We were honored to be included in this conference and were impressed with the quality of questions that stemmed from the pannel discussion. If you want to...
A simple example that shows how pdfHTML can be used in conjuction with screen size mediaqueries and floating elements to create different PDFs using responsive webdesign.
A simple example showcasing the creation of a Tagged PDF with pdfHTML, and the configuration to include the metadata, necessary to obtain an Accessible PDF.
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...