New method: puppeteer + cli wrapper
Puppeteer is the new best way to build PDFs from html. It is a headless chrome browser being maintained as an NPM package by the official Chromium development team. While wkhtmltopdf
hasn’t been updated in a while and is lacking most newer browser features (notably flex layouts), puppeteer benefits from being kept current with the newest chromium releases. Previous efforts have all been by 3rd parties reverse-engineering and trying to keep up with browser engines, while this is the first effort that is a first-class supported effort by a browser engine team. It is exposed as a node API for doing a lot more than just turing pages into PDFs, and to that end I’ve built a simple cli wrapper for generating PDFs:
I’m trying to get the CLI buildable under habitat for easier distribution to servers, but in the meantime the CLI can installed via npm by using npm install -g puppeteer-cli
(due to puppeteer#375 this must currently be done using npm install -g puppeteer-cli --unsafe-perm=true
). Emergence will need to be updated to make use of a puppeteer print
command if available instead of wkhtmltopdf
Old method
wkhtmltopdf is no longer being supported
- Download the latest stable binaries from http://wkhtmltopdf.org/downloads.html
- Place in
/usr/local/bin
- Ensure
wkhtmltopdf
andwkhtmltoimage
are executable by all and owned by root