Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obinoob/f4a569d45e1a13fa3d431ab329acefad to your computer and use it in GitHub Desktop.
Save obinoob/f4a569d45e1a13fa3d431ab329acefad 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