How to Install wkhtmltopdf on Ubuntu Server 14.04

I wanted to use wkhtmltopdf on an Ubuntu 14.04 webserver. After downloading the binaries they came up with errors. Here is how to install it properly using xvfb.

How to Install wkhtmltopdf on Ubuntu Server 14.04

I wanted to use wkhtmltopdf on an Ubuntu 14,04 webserver. Up to now I have been always working with the binaries directly. However, after I downloaded the binaries from http://wkhtmltopdf.org/ these came up with the following error:


./wkhtmltox-i386.deb: line 1: syntax error near unexpected token `newline'
./wkhtmltox-i386.deb: line 1: `!'

As I did not have much more time to lose, I followed the tutorial here (which dated almost 2 years ago, and was for Ubuntu 12.04). After some minor adjustments, was able to produce the desired result. Here is the code snippet:


apt-get install wkhtmltopdf
apt-get install xvfb
echo 'xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
chmod a+rx /usr/bin/wkhtmltopdf.sh
ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
/usr/bin/wkhtmltopdf.sh `http://www.google.com output.pdf`

Awesome job Ashish Kulkarni, and Jakob Truelsen for developing this awesome piece of software wkhtmltopdf, and Fedir Rykhtik for compiling the script above.

Keep Reading

Explore more articles and insights

Ork: SSH Server Automation in Go

Ork: SSH Server Automation in Go

Read Article
Deno Deploy Killed My Start Page

Deno Deploy Killed My Start Page

Read Article
Back to Golang: Why I Switched From Static to Dynamic Again

Back to Golang: Why I Switched From Static to Dynamic Again

Read Article
View All Blog Posts