pdfHTML

Installing iText 7 pdfHTML for .NET developers

We will walk you through the installation process, from downloading iText 7 pdfHTML to adding the dependency to your Java building tool.

Installing iText 7 pdfHTML for Java developers

We will walk you through the installation process, from downloading iText 7 pdfHTML to adding the dependency to your Java building tool.

pdfHTML: Convert HTML/CSS to PDF

In this white paper, you'll learn how to convert HTML5 and CSS3 into PDF documents with this iText 7 add-on. By integrating a simple API to your workflow, you can create standards compliant PDF documents that are accessible, searchable and usable for indexing.

Get the eBook "Converting HTML to PDF with pdfHTML"

Use HTML and CSS to create templates for your PDF files.

Table of contents:

  • Chapter 1: Hello HTML to PDF
  • Chapter 2: Defining styles with CSS
  • Chapter 3: Generating PDFs based on Media Queries
  • Chapter 4: Creating reports using pdfHTML
  • Chapter 5: Custom tag workers and CSS appliers
  • Chapter 6: Using fonts in pdfHTML
  • Chapter 7: Frequently Asked Questions about pdfHTML
Create PDF from HTML and CSS
About the book
In this book, you will learn how to generate PDF documents using HTML and CSS as a template format with iText 7 pdfHTML.
Image
eBook cover pdfHTML
Subtitle
eBook - free copy
Campaign Details

How does it work?

  • Fill out the form on the right.
  • On the thank you page you will get a direct link to our online book page.
  • You will receive an e-mail with a link to download the free PDF or EPUB version on LeanPub.
Campaign Embed form

Get your free copy

Why do I have to pay for pdfhtml during my upgrade, when I already have XML Worker in iText?

iText 7: Converting HTML to PDF with pdfHTML

NOTE: We are continually updating our features- and have some new features that are not included in this eBook yet.  You can find a full list of features here.

Introduction

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 obsolete HTMLWorker class (iText 2), or the old XML Worker add-on (iText 5).

The HTMLWorker class was deprecated many years ago. The goal of HTMLWorker was to convert small, simple HTML snippets to iText objects. It was never meant to convert complete HTML pages to PDF, yet that was how many developers tried to use it. This caused plenty of frustration because HTMLWorker didn't support every HTML tag, didn't parse CSS files, and so on. To avoid this frustration, HTMLWorker was removed from recent versions of iText.

In 2011, iText Group released XML Worker as a generic XML to PDF tool, built on top of iText 5. A default implementation converted XHTML (data) and CSS (styles) to PDF, mapping HTML tags such as <p>, <img>, and <li> to iText 5 objects such as Paragraph, Image, and ListItem. We don't know of any implementations that used XML Worker for any other XML formats, but many developers used XML Worker in combination with jsoup as an HTML2PDF converter.

XML Worker wasn't a URL2PDF tool though. XML Worker expected predictable HTML created for the sole purpose of converting that HTML to PDF. A common use case was the creation of invoices. Rather than programming the design of an invoice in Java or C#, developers chose to create a simple HTML template defining the structure of the document, and some CSS defining the styles. They then populated the HTML with data, and used XML Worker to create the invoices as PDF documents, throwing away the original HTML. We'll take a closer look at this use case in chapter 4, converting XML to HTML in memory using XSLT, then converting that HTML to PDF using the pdfHTML add-on.

When iText 5 was originally created, it was designed as a tool to produce PDF as fast as possible, flushing pages to the OutputStream as soon as they were finished. Several design choices that made perfect sense when iText was first released in the year 2000, were still present in iText 5 sixteen years later. Unfortunately, some of these choices made it very difficult –if not impossible– to extend the functionality of XML Worker to the level of quality many developers expected. If we really wanted to create a great HTML to PDF converter, we would have to rewrite iText from scratch. Which we did.

In 2016, we released iText 7, a brand new version of iText that was no longer compatible with previous versions, but that was created with pdfHTML in mind. A lot of work was spent on the new Renderer framework. When a document is created with iText 7, a tree of renderers and their child-renderers is built. The layout is created by traversing that tree, an approach that is much better suited when dealing with HTML to PDF conversion. The iText objects were completely redesigned to better match HTML tags and to allow setting styles "the CSS way."

For instance: in iText 5, you had a PdfPTable and a PdfPCell object to create a table and its cells. If you wanted every cell to contain text in a font different from the default font, you needed to set that font for the content of every separate cell. In iText 7, you have a Table and Cell object, and when you set a different font for the complete table, this font is inherited as the default font for every cell. That was a major step forward in terms of architectural design, especially if the goal is to convert HTML to PDF.

But let's not dwell on the past, let's see what pdfHTML can do for us. In the first chapter, we'll take a look at different variations of the convertToPdf() method, and we'll discover how the converter is configured.

E-book cover image
Image
eBook cover pdfHTML
book nid
3686
Subtitle
eBook

Release iText 7.1.4

iText 7.1.4 is the fourth maintenance release for iText 7 Core/Community. We're also updating pdfHTML, pdfCalligraph, RUPS and our License Key and Volume License Key Library.

Release iText 7.0.2

For this release, we have added some a minor updates to our iText 7 platform, version 7.0.2. As well as some updates for the License Key Library, pdfHTML and pdfCalligraph.

Release iText 7.0.5

iText 7.0.5 is a scheduled maintenance release for iText 7 Community. We're also updating pdfSweep to 1.1.0, pdfHTML to 1.0.2, pdf2Data to 1.2.0, and pdfInvoice to 1.0.2.

Release iText 7.0.8

iText 7.0.8 is a scheduled maintenance release for iText 7.0 Core/Community. We're also updating pdfHTML to 1.0.5. The releases contain only backported fixes from 7.1.x to accommodate customers who are still on iText 7.0.
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now