Migration guides · ERP

Replace wkhtmltopdf with pdfkiln in Frappe and ERPNext

Frappe and ERPNext print with the wkhtmltopdf in the PATH. Their print formats put headers and footers in --header-html and --footer-html pages, filled by JavaScript.

1. Install pdfkiln

On Debian and Ubuntu, amd64 and arm64: the signed APT repository installs /usr/bin/wkhtmltopdf in place of the wkhtmltox package, and brings Chromium’s fixes with apt upgrade.

curl -fsS https://apt.pdfkiln.org/pdfkiln-archive-keyring.asc | sudo tee /usr/share/keyrings/pdfkiln-archive-keyring.asc > /dev/null
printf 'Types: deb\nURIs: https://apt.pdfkiln.org\nSuites: stable\nComponents: main\nSigned-By: /usr/share/keyrings/pdfkiln-archive-keyring.asc\n' \
  | sudo tee /etc/apt/sources.list.d/pdfkiln.sources
sudo apt update && sudo apt install pdfkiln

Elsewhere: the Docker image, the archives and the Windows installer.

2. Point Frappe and ERPNext at it

Nothing to configure: Frappe finds the program in the PATH.

3. Check

wkhtmltopdf --version
# wkhtmltopdf 0.12.6 (with patched qt), pdfkiln 1.0.4, Chromium 156.0.8078.80

The answer starts as wkhtmltopdf 0.12.6’s does: libraries that read the version keep working.

What Frappe and ERPNext expects, and what pdfkiln does

  • Frappe looks for qt in wkhtmltopdf --version to know whether HTML headers and footers work: pdfkiln keeps (with patched qt) in its answer for that.
  • Header and footer pages run their JavaScript and load their images even with --disable-javascript and --no-images, which reach only the printed page, as in wkhtmltopdf: Frappe’s footer fills in “Page 1 of 2” by script.
  • Table rows that do not fit at the bottom of a page move whole to the next one, and thead repeats on every page, as with wkhtmltopdf.

Tested

The ERPNext 15 print formats of the 32-template corpus keep their page count against wkhtmltopdf 0.12.6 (Linux).

Something renders differently? Open an issue with the HTML and both PDFs: github.com/Jamalofski/pdfkiln/issues. The known differences are listed in the README.