Skip to content

Instantly share code, notes, and snippets.

@Oxicode
Forked from brunogaspar/README.md
Created March 1, 2017 21:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Oxicode/062649ad798ffb8ce16c720d3202acf2 to your computer and use it in GitHub Desktop.
Save Oxicode/062649ad798ffb8ce16c720d3202acf2 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 http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb

Step 3

Install wkhtmltopdf:

sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb

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

@zacrify
Copy link

zacrify commented Aug 9, 2017

@saberanaibi
Copy link

you have to be connected to the internet

@raghuroundsqr
Copy link

am getting error like

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.

@mike1011
Copy link

i also had to run the below commands to setup latest version on my ubuntu-19


sudo add-apt-repository ppa:linuxuprising/libpng12
sudo apt update
sudo apt install libpng12-0

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.trusty_amd64.deb

@Eeshanyainfra
Copy link

will it support to ubuntu os 14.04 version now?

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