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

Tags: pdfHtmlHTML to PDFparsing HTML

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.

However, pdfHTML doesn't support SVG for now, nor does it evaluate JavaScript. Support for SVG is on the development roadmap, and 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.