4 ms·
IMO puppeteer is the best way to go now, it's maintained by the Chrome team and uses officially supported developer APIs: https://github.com/GoogleChrome/puppet
by jarvuschris 8y ago
IMO puppeteer is the best way to go now, it's maintained by the Chrome team and uses officially supported developer APIs: https://github.com/GoogleChrome/puppeteer https://github.com/GoogleChrome/puppeteer
I built a basic CLI wrapper to make it easy to drop it in in place of wkhtmltopdf: https://www.npmjs.com/package/puppeteer-cli https://www.npmjs.com/package/puppeteer-cli
I've used wkhtmltopdf heavily for years and it is a disaster today. Font rendering is inconsistent across systems, its CSS/HTML support is frozen in time many years ago.
The author's suggested alternative doesn't use a real browser rendering engine, it uses its own CSS/HTML parsing and rendering implementations (!!!). I don't trust it to keep up with standards and don't want content authors to have to deal with yet another dialect of HTML/CSS with its own pile of quirks. We already know Chrome's capabilities and quirks and I'm quite happy with Chrome's print menu and the output of my backend PDF generator being the same thing.
> The CSS layout engine is written in Python, designed for pagination, and meant to be easy to hack on.
Raise your hand if you want to hack on a CSS layout engine in Python while generating your PDFs. I'll wait
- TobalJackson 8y agoCame here to mention puppeteer since I didn't see it in the author's suggestions. I developed a huge script at my last job which processed PST files into PDFs, and it relied heavily on wkhtmltopdf. After discovering the issues surrounding font embedding and lack of interoperability with windows/adobe acrobat (when redacting) I was tearing my head out trying to figure out how to get it to work. In the end, I chalked it up to being a limitation of how the program handled fonts, and looked for an alternative. After discovering puppeteer and dropping it in (replacing wkhtmltopdf), basically all the problems I was having with fonts disappearing were solved. Did not look back.
- kyriakos 8y agoWkhtmltopdf still has better support for headers and footers. Puppeteer/chrome still lacks in this feature but it's getting there.
- unilynx 8y agoAnd to add to this: for the other side of the equation (watermarking/backgrounds, joining, splitting, pdf to img) use Apache's PDFBox I've been through so many combinations of fop/flyingsaucer/wkhtmltopdf/phantom and pdftk/mcpdf/qpdf over the last decade.... but it seems we're finally about to solve this problem...