WKHTMLTOPDF is a very handy binary tool to create PDF from HTML. I used it already in many projects and I am very happy with the results.
But the initial setup could be a little tricky if you don’t know your way around a Linux server. The following procedure works for me with WKHTMLTOPDF v.0.12.3 on Ubuntu Server 14.04 or 16.04:
- Go to WKHTMLTOPDF downloads page and copy URL for the linux stable version
- Download latest stable file from WHTMLTOPDF site and put it in a temporary folder e.g.:
cd /tmp && wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-i386.tar.xz
- Extract with tar
tar xf wkhtmltox-0.12.4_linux-generic-i386.tar.xz
- Move into /opt (or whatever path you prefer)
mv /tmp/wkhtmltox /opt/
- Install dependencies. Ubuntu 14.04:
apt-get install libXrender1 fontconfig libXext6
apt-get install libxrender1 fontconfig libxext6
- Create a symlink
cd /usr/local/bin && ln -s /opt/wkhtmltox/bin/wkhtmltopdf
Important: if you get an error “cannot execute binary file: Exec format error” it means you need the 32bit version instead. Use the same procedure as above but replace “amd64” with “i386“.
If your dependencies were already automatically installed as dependencies from another package, you may want to mark them as manual. So if you remove that other package, they will not be listed as “unused”.
apt-mark manual libXrender1 fontconfig libXext6