Skip to content

Instantly share code, notes, and snippets.

@itzikbenh
Last active December 14, 2022 13:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save itzikbenh/7af73a35039032f6ab89f3f7ffb83688 to your computer and use it in GitHub Desktop.
Save itzikbenh/7af73a35039032f6ab89f3f7ffb83688 to your computer and use it in GitHub Desktop.
Install wkhtmltopdf in Ubuntu 16.04.1 so you can use Laravel Snappy.
//Get package
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo apt install wkhtmltopdf
//create symlink.
sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
//At this point you can run this command to test that everything works.
/usr/local/bin/wkhtmltopdf google.com google.pdf
//Command above will give you the following error - QXcbConnection: Could not connect to display Aborted (core dumped)
//This is due to a bug in the debian packages, or something like that :)
//Solution taken from here - http://unix.stackexchange.com/questions/192642/wkhtmltopdf-qxcbconnection-could-not-connect-to-display
sudo apt install xvfb
//Now in the snappy config file change this
'binary' => '/usr/local/bin/wkhtmltopdf',
//To
'binary' => '/usr/bin/xvfb-run -- /usr/local/bin/wkhtmltopdf',
It should work now.
@mat-dudziak
Copy link

Thx you so much! You saved me a lot of time!

@akramabdulrahman
Copy link

akramabdulrahman commented Aug 24, 2017

thank you , the url above no longer works , i'd recommend heading here , copy the link and feed it to wget .

just in case anyone needs this .

@zeshan-inquiron
Copy link

Thanks - This works well.

@pjc1john
Copy link

Thank you! You saved my Day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment