Skip to content

Instantly share code, notes, and snippets.

@motsmanish
Forked from Oxicode/README.md
Last active March 14, 2018 13:17
Show Gist options
  • Save motsmanish/9ab930016a2913df045579b94615222a to your computer and use it in GitHub Desktop.
Save motsmanish/9ab930016a2913df045579b94615222a to your computer and use it in GitHub Desktop.
Install wkhtmltopdf on Ubuntu 14.04 64-bit

Install wkhtmltopdf on Ubuntu

This was tested on:

  • Ubuntu 14.04 x64
  • Ubuntu 16.04 x64

Step 1

Install the xvfb server by running

sudo apt-get install xvfb

Step 2

Get the latest stable version wkhtmltopdf from http://wkhtmltopdf.org/downloads.html page.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

Step 3

Install wkhtmltopdf:

unxz wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar

If you see dependencies errors while installing, you'll need to run the following

sudo apt-get -f install

Now that the dependencies are installed just run the install command, again.

Step 4

Create a symbolic link in /usr/local/bin/:

echo 'exec xvfb-run -a -s "-screen 0 640x480x16" wkhtmltopdf "$@"' | sudo tee /usr/local/bin/wkhtmltopdf.sh >/dev/null && sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh

Step 5

Test that everything is working as expected

wkhtmltopdf http://www.google.com google.pdf

If you see Done then everything is installed correctly and you're ready to generate some PDF's :D

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