Installing wkhtmltopdf on Ubuntu 14.04 and 16.04

Published on August 8, 2017 by

Installing wkhtmltopdf on Linux can be a bit tricky, especially for people who are not so familiar with *nix operating systems. There are various ways in which you can install wkhtmltopdf; use a package manager such as apt-get, compile from source, or download the pre-compiled binary file. We are going to be doing the latter in this tutorial.

Now the installation instructions for wkhtmltopdf have changed over the years, but as of this writing, the commands that you are about to see work for Ubuntu 14.04 and Ubuntu 16.04.

Installing wkhtmltopdf Dependencies

First, we need to install a couple of wkhtmltopdf dependencies.

apt-get install libfontconfig \
    zlib1g \
    libfreetype6 \
    libxrender1 \
    libxext6 \

Downloading & Extracting Archive

Then we will download and extract an archive containing the binary file. Be sure to update the link to use whichever version you prefer. You can find the links on the download page over at

curl -L -o wkhtmltopdf.tar.xz
tar -xf wkhtmltopdf.tar.xz

Moving Binary File & Permissions

Now we have a directory named wkhtmltox within our current working directory. This directory contains the binary file that we are looking for within the bin directory, namely wkhtmltopdf. We could just use that binary file from that directory as is, but we probably want to make wkhtmltopdf available throughout the system. To do that, we need to move it and give it permission to execute.

mv wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf

Testing wkhtmltopdf

You can test if wkhtmltopdf is working as intended by generating a PDF file with contents of

wkhtmltopdf google.pdf

I will try to stay up to date with any changes, but these things change quite often. So if the above does not work out for you, please let me know in the comments.

Author avatar
Bo Andersen

About the Author

I am a back-end web developer with a passion for open source technologies. I have been a PHP developer for many years, and also have experience with Java and Spring Framework. I currently work full time as a lead developer. Apart from that, I also spend time on making online courses, so be sure to check those out!

8 comments on »Installing wkhtmltopdf on Ubuntu 14.04 and 16.04«

  1. Romain

    Thanks for this really well explained blog post. It worked like a charm.


  2. Marie

    Hello I have to do this on Ubuntu 16.04.3 LTS

    sudo apt-get install libssl-dev=1.0.2g-1ubuntu4.10

    instead of

    apt-get install libssl1.0.0=1.0.2g-1ubuntu4.8

    thank you again :)

  3. Vikas

    Thanks Marie, it worked.

  4. Joe

    I had trouble finding the exact last digit for different servers and found that omitting it worked in all scenarios I tried.

    sudo apt-get install libssl-dev=1.0.2g-1ubuntu4
  5. Laurent Cetinsoy

    Thanks for the blog and thanks Marie for the last workaround !

  6. Hello Sam,

    It looks like the issue has been fixed. Although I haven’t tested it out, I went ahead and removed the fix from the post. Thanks for the heads up! :-)

  7. Sam DeVore

    I’m going to spin up some docker containers this weekend and see if it looks fixed. Would be nice not have to work around this issue anymore. Also thanks again for having this up, saved my bacon.


Leave a Reply

Your e-mail address will not be published.