Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save destinydriven/26ab2df5c8bfc635fba21b187397b8f0 to your computer and use it in GitHub Desktop.
Save destinydriven/26ab2df5c8bfc635fba21b187397b8f0 to your computer and use it in GitHub Desktop.
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 1024x768x24" 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
Now just ensure that your Plugin configuration for CakePdf looks like this:
$config['CakePdf'] = array(
'engine' => 'CakePdf.WkHtmlToPdf',
'binary' => '/usr/local/bin/wkhtmltopdf.sh',
'pageSize' => 'legal',
);
The CakePdf script should be calling your script (*.sh rather than the binary file directly)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment