HTML to PDF

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.

Undefined

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.

Undefined

Chapter 7: Frequently Asked Questions about pdfHTML

How to convert an ASP or JSP page to PDF? How to parse multiple HTML files into one PDF? Can pdfHTML render Base64 images to PDF? Can I generate a PDF from a URL instead of from a file on disk? Do we need a browser engine to render HTML+CSS to PDF Does my HTML have to be valid XML? How to add metadata to a PDF using pdfHTML? How do the measurement systems in HTML relate to the measurement system in PDF? Can I convert an HTML form to a PDF? How to render certain HTML entities (such as arrows) to PDF? Why can't I embed a font due to licensing restrictions? Which languages are supported in pdfHTML? How to convert HTML containing Arabic/Hebrew characters to PDF? Why is my PDF missing several characters?

Undefined

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:

Undefined

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.

Undefined

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.

Undefined