Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install wkhtmltopdf on Ubuntu (14.04 64-bit) or (16.04 64-bit)

Install wkhtmltopdf on Ubuntu

This was tested on:

  • Ubuntu 14.04 x64
  • Ubuntu 16.04 x64

Installation

sudo apt-get update
sudo apt-get install xvfb libfontconfig wkhtmltopdf

Test

Now it's time to 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

@mgomma

This comment has been minimized.

Copy link

commented Jan 27, 2017

It returns -bash: /usr/bin/wkhtmltopdf: No such file or directory
Ubunut 16.04
Run that command fixed it to me sudo ln -s /usr/local/bin/wkhtmlto /usr/bin/wkhtmltopdf

@lsirluis

This comment has been minimized.

Copy link

commented Apr 18, 2017

Thank!!!, thank you very much, 2 days trying to make wkhtmltopdf work in my vps without solution and in 2 minutes making this steps and its done!, thank you, greeting from colombia.

@marvoh

This comment has been minimized.

Copy link

commented Apr 23, 2017

Thanks! This helped

@BryanTabarez

This comment has been minimized.

Copy link

commented Apr 24, 2017

Why not from default ubuntu repositories?

sudo apt-get update
sudo apt-get install xvfb
sudo apt-get install wkhtmltopdf

(tested in ubuntu 14.04 x64)

@ramsesrom

This comment has been minimized.

Copy link

commented May 25, 2017

root@mail:~# wkhtmltopdf http://www.google.com google.pdf Loading pages (1/6)
Segmentation fault ] 10%

what to do here?

@mridzuan

This comment has been minimized.

Copy link

commented Jun 15, 2017

Please be informed that gna.org has been taken down.

@yusufyilmaz

This comment has been minimized.

Copy link

commented Jun 29, 2017

Tested on a brand new Ubuntu 16.04 server. It throws an error
QXcbConnection: Could not connect to display

@zloynemec

This comment has been minimized.

Copy link

commented Jun 29, 2017

@yusufyilmaz it works perfectly with the following command:
xvfb-run wkhtmltopdf http://google.com google.pdf

@Greentash

This comment has been minimized.

Copy link

commented Jul 6, 2017

Thanks @brunogaspar, you make my day. Bigup yourself !!!
i was suffering by that install odoo 8

@dilab

This comment has been minimized.

Copy link

commented Jul 17, 2017

This will not get you the latest version tho

@ghost

This comment has been minimized.

Copy link

commented Aug 16, 2017

I am facing the following issue with my ubantu-16.04

Error: /bin/bash: wkhtmltopdf: command not found 

I used the which wkhtmltopdf command and got the following:

/usr/local/bin/wkhtmltopdf

And I also checked the $PATH variable using echo $PATH its giving the following output:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

How to fix this?

@agungjk

This comment has been minimized.

@aruprakshit

This comment has been minimized.

Copy link

commented Oct 31, 2017

I am getting below error:

The switch --footer-right, is not support using unpatched qt, and will be ignored.The switch --footer-font-size, is not support using unpatched qt, and will be ignored.The switch --footer-center, is not support using unpatched qt, and will be ignored.The switch --header-html, is not support using unpatched qt, and will be ignored.The switch --header-spacing, is not support using unpatched qt, and will be ignored.The switch --footer-spacing, is not support using unpatched qt, and will be ignored.wkhtmltopdf: cannot connect to X server
Errno::EPIPE: Broken pipe

How to solve this?

@joshuapinter

This comment has been minimized.

Copy link

commented Nov 14, 2017

Steps for install 0.12.3 on Ubuntu 16.04.

Because I wasted way too much time tracking this down, here is for others stumbling on this.

You don't want to use apt-get because it's out-of-date. I'm not a *nix expert but I have no idea why it takes so long for these updated packages to get pushed upstream to the repositories.

Just to help others, here is what my installation steps were installing 0.12.3 on Ubuntu 16.04:

cd ~
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
tar vxf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz 
cp wkhtmltox/bin/wk* /usr/local/bin/

And you can confirm with:

$ wkhtmltopdf --version
wkhtmltopdf 0.12.3 (with patched qt)

Btw, I chose 0.12.3 instead of 0.12.4 because of a strange page sizing issue, discussed here:

wkhtmltopdf/wkhtmltopdf#3226

@arriouach

This comment has been minimized.

Copy link

commented Dec 3, 2017

Thanks, its helpful

@andrewduan

This comment has been minimized.

Copy link

commented Dec 12, 2017

Hi @aruprakshit,
I am facing the same problem. have you found a way to solve the broken pipe issue?

@wlchn

This comment has been minimized.

Copy link

commented Dec 27, 2017

@joshuapinter Thanks, its helpful, I chose 0.12.3 for same reason.

@ihr-it-projekt

This comment has been minimized.

Copy link

commented Jan 4, 2018

@yusufyilmaz I have the same problem

QXcbConnection: Could not connect to display

Do you have a solution?

@vankov1

This comment has been minimized.

Copy link

commented Jan 14, 2018

@ihr-it-projekt try using /usr/bin/xvfb-run /usr/bin/wkhtmltopdf (Check your path to wkhtmltopdf it can be /usr/local/bin/wkhtmltopdf)

@kai101

This comment has been minimized.

Copy link

commented Jan 25, 2018

I have made a small deployment instruction here

https://gist.github.com/kai101/99d57462f2459245d28b4f5ea51aa7d0

@H1D1

This comment has been minimized.

Copy link

commented Mar 6, 2018

retourner QXcbConnection: Could not connect to display

@saberanaibi

This comment has been minimized.

Copy link

commented Mar 15, 2018

you have to be connected to the internet

@nitinnath

This comment has been minimized.

Copy link

commented Mar 21, 2018

nice brother

@festusngor

This comment has been minimized.

Copy link

commented Apr 19, 2018

See https://gist.github.com/srmds/2507aa3bcdb464085413c650fe42e31d for Installing wkhtmltopdf 0.12.4 on Ubuntu 16.04

@deivid11

This comment has been minimized.

Copy link

commented Sep 6, 2018

Solution for QXcbConnection: Could not connect to display:
alias wkhtmltopdf='xvfb-run wkhtmltopdf'

@kunicmarko20

This comment has been minimized.

Copy link

commented Sep 8, 2018

Thank you @deivid11

@damuz91

This comment has been minimized.

Copy link

commented Oct 4, 2018

@Pedro75

This comment has been minimized.

Copy link

commented Nov 15, 2018

When I test the result is :
wkhtmltopdf: cannot connect to X server
Installed on ubuntu 14.04
Anyone can help me?

@ajaychauhan727

This comment has been minimized.

Copy link

commented Feb 18, 2019

@joshuapinter I followed your step to install it. Seems installed but i get following error while checking --version

wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

& to solve that I followed below link. Which makes it finally work proper.

https://www.cyberciti.biz/faq/debian-ubuntu-linux-wkhtmltopdf-error-while-loading-shared-libraries-libxrender-so-1/

@NaitikShah

This comment has been minimized.

Copy link

commented Apr 22, 2019

Thanks, @brunogaspar it works!

@pvin

This comment has been minimized.

Copy link

commented May 4, 2019

In production server (ubuntu 14.04) getting this error

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

/usr/local/rvm/gems/ruby-2.5.1/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf_linux_x86: 1: /usr/local/rvm/gems/ruby-2.5.1/gems/wkhtmltopdf-binary-0.12.4/bin/wkhtmltopdf_linux_x86: Syntax error: word unexpected (expecting ")")

Any help @brunogaspar @yusufyilmaz @brunogaspar

@brunogaspar

This comment has been minimized.

Copy link
Owner Author

commented May 5, 2019

@pvin I've created 2 new servers to test one with Ubuntu 14.04 x64 and the other with Ubuntu 16.04 x64 and in both instances it worked as expected.

Try to reinstall wkhtmltopdf and see if that helps.

Sorry for not being of much help, but i'm unable to reproduce :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.