Skip to main content
Skip table of contents

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

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.

However, pdfHTML doesn't support SVG for now, nor does it evaluate JavaScript.

SVG support for pdfHTML was added with release 2.1.0, when we first introduced the SVG module with iText Core version 7.1.3 in September 2018. iText’s support of SVG has been continually updated and improved in subsequent versions.

However, you could solve the JavaScript problem by using a browser engine to preprocess the HTML+CSS+JS. Examples of such a browser engine are WebKit (Chrome, Safari) and Gecko (Firefox). These can interpret the JavaScript and give you HTML that can be rendered by pdfHTML.

See for an example of such HTML+CSS+JS preprocessing using Selenium WebDriver and Headless Chrome.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.