The Problem
wkhtmltopdf is a library for rendering PDFs from HTML or live web pages.
- apt-get install wkhtmltopdf will install the older 0.9 version, which isn’t compatible with the Snappy PHP wrapper
- wkhtmltopdf 0.9 is also unable to render on ‘headless’ operating systems and needs another package to simulate a display. The newer 0.12 version doesn’t have this problem.
The Solution
Manually Install the ‘Static’ Binary from wkhtmltopdf.org
(NB: If you’re not a root or super user most commands will need to be sudo…)
Download the Ubuntu “Trusty” build.
At the time of writing this is wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
Rename it something easy to type like wkhtml.deb
Extract it with this command
ar x wkhtml.deb # if ar not installed run this: # apt-get install binutils
Extract the binary
tar xf data.tar.xz
Move the binary file to /usr/bin
mv wkhtmltopdf /usr/bin/wkhtmltopdf
Now PDF Rendering Should Work
wkhtmltopdf http://example.com myTest.pdf