In 2025, the best and primary method for generating PDFs is to use headless Chrome through libraries such as Puppeteer and Playwright, because Chrome provides full support for CSS features like Flexbox, Grid, etc. The main downside is that launching Chrome consumes resources, and when handling a large number of documents, you need to decide whether to scale and maintain your own infrastructure or to use a third-party API like PDFBolt.
When it comes to generating an invoice from a template, check out this blog post which, in addition to comparing various PDF generation technologies, includes a tutorial on how to generate a PDF invoice from a template in Node.js using Playwright and an EJS template: How to generate PDFs in 2025