Hacker News new | ask | show | jobs
by ithrow 1604 days ago
For generating PDFs like invoices in a webapp, is libraries like this the way to go these days or is still using a pdf lib the norm?

Pros of Playwright/Puppeteer:

Reuse existing HTML/CSS knowledge

Cons: Requires an external service or shelling out to an external process

Pros of using a pdf lib:

Probably better performance, simpler architecture by being in-process.

Cons: Ad-hoc language for designing the PDF.

1 comments

It's very simple to use either, there are loads of example implementations on GitHub.

I used one based on docker, and the bottleneck was actually sending the html, css you want to print (if it's not already served over http). I used a shared docker volume to write to from one process (python) and read from another (the node pupetter).

It all comes down to, load html, wait to load, save to pdf. Very simple, fast, and reliable. More so than weasyprint for example.