Do we need a browser engine to render HTML+CSS to PDF

Similar questions were posted on Stack Overflow on May 23, '13 by Kaha and on Aug 14, '17 by Srinivas Ch

No, pdfHTML does all the work parsing the HTML and CSS, and mapping them to iText objects and styles. Then the iText engine renders the PDF based on these objects and styles.


How to parse multiple HTML files into one PDF?

This question was originally posted on Stack Overflow on January 6, 2015 by kyzh101

There are two answers to this question. Answer #2 is generally better than answer #1, but I'm giving both options because there may be specific cases where answer #1 is preferred.


Chapter 7: Frequently Asked Questions about pdfHTML

Over the years, we've received many questions about converting PDF to HTML.

In this chapter, we'll answer those questions that were asked most frequently.


Chapter 6: Using fonts in pdfHTML

Up until now, we haven't spent much attention to the fonts that were used when we converted HTML to PDF. We know that Helvetica is the default font used by iText when no font is specified (chapter 2), and we know that pdfHTML ships with some built-in fonts if you need to embed a font (chapter 4), but we didn't get a clear overview of which fonts are supported as of yet.

There are two things you need to know before reading this chapter:


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 documents 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 look at different snippets of HTML and CSS.