or try this (from http://drupal.org/node/870058)
-
Download wkhtmltopdf. Or better install it with a package manager:
sudo apt-get install wkhtmltopdf
-
Extract it and move it to
/usr/local/bin/
- Rename it to
wkhtmltopdf
so that now you have an executable at/usr/local/bin/wkhtmltopdf
- Set permissions:
sudo chmod a+x /usr/local/bin/wkhtmltopdf
-
Install required support packages.
sudo apt-get install openssl build-essential xorg libssl-dev
-
Check to see if it works: run
/usr/local/bin/wkhtmltopdf http://www.google.com test.pdf
If it works, then you are done. If you get the error “Cannot connect to X server” then continue to number 7.
-
We need to run it headless on a ‘virtual’ x server. We will do this with a package called xvfb.
sudo apt-get install xvfb
-
We need to write a little shell script to wrap wkhtmltopdf in xvfb. Make a file called
wkhtmltopdf.sh
and add the following:xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "$@"
-
Move this shell script to
/usr/local/bin
, and set permissions:sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh
-
Check to see if it works once again: run
/usr/local/bin/wkhtmltopdf.sh http://www.google.com test.pdf
Note that http://www.google.com may throw an error like “A finished ResourceObject received a loading finished signal. This might be an indication of an iframe taking to long to load.” You may want to test with a simpler page like http://www.example.com
.