wkhtmltopdf 0.12 on Ubuntu 14.04

The Problem

wkhtmltopdf is a library for rendering PDFs from HTML or live web pages.

  • apt-get install wkhtmltopdf  will install the older 0.9 version, which isn’t compatible with the Snappy PHP wrapper
  • wkhtmltopdf 0.9 is also unable to render on ‘headless’ operating systems and needs another package to simulate a display. The newer 0.12 version doesn’t have this problem.

The Solution

Manually Install the ‘Static’ Binary from wkhtmltopdf.org

(NB: If you’re not a root or super user most commands will need to be sudo…)

Download the Ubuntu “Trusty” build.
At the time of writing this is wkhtmltox-

wget http://downloads.sourceforge.net/project/wkhtmltopdf/

Rename it something easy to type like wkhtml.deb

Extract it with this command

ar x wkhtml.deb
# if ar not installed run this:
# apt-get install binutils

Extract the binary

tar xf data.tar.xz

Move the binary file to /usr/bin

mv wkhtmltopdf /usr/bin/wkhtmltopdf

Now PDF Rendering Should Work

wkhtmltopdf http://example.com myTest.pdf

3 thoughts on “wkhtmltopdf 0.12 on Ubuntu 14.04

  1. Hi Mike

    I followed your instructions.
    On step “mv wkhtmltopdf /usr/bin/wkhtmltopdf” got error message saying mv: cannot stat ‘wkhtmltopdf’: No such file or directory

    After that cound not access tmp anymore: permissions denied. Got that solved.

    Now I get this message: mktemp: failed to create file via template ‘/tmp/virtualenvwrapper-initialize-hook-XXXXXXXXXX’: Permission denied
    ERROR: virtualenvwrapper could not create a temporary file name.
    What went wrong? I did all commands by using sudo prefix. The server is Ubuntu 14.04

    1. Hm, sorry it didn’t go smoothly for you Tero.

      It’s been a while since I last did this. I ran through the process again and this time needed to install a few dependencies with this command:
      sudo aptitude install openssl build-essential xorg libssl-dev libxrender-dev

      However none of my errors were similar to yours. I haven’t encountered that.
      Googling virtualenvwrapper it seems like that tool might be specific to some a Virtual Environment manager (?). It could be that there’s a problem with user permissions in that environment. Maybe the wkhtmltopdf binary cannot write to the virtualenvwrapper temp directory?

      I did this on a Digital Ocean server, using the root account created when I started the droplet.
      Sorry I can’t help.

Leave a Reply

Your email address will not be published. Required fields are marked *