Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save tejastank/45b6eba13fb38e24110218e3ce50129b to your computer and use it in GitHub Desktop.
Save tejastank/45b6eba13fb38e24110218e3ce50129b to your computer and use it in GitHub Desktop.
Wkhtmltopdf failed (error code: -6). Message: The switch --header-spacing, 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 --footer-html, is not support using unpatched qt, and will be ignored.QXcbConnection: Could not connect to display. # https:/…
# https://www.snippetbucket.com/
# ODOO ERP Django PHP Android AngularJS implementation and customization.
# Most Simple and Quick Way:
sudo su
cd /opt
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
mv wkhtmltox/bin/wkhtmlto* /usr/bin/
#or below
cd /opt/
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)
###### That's it
# More over.....
#for debian stretch version
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb
# for other
https://github.com/wkhtmltopdf/wkhtmltopdf/releases/0.12.5
# long way procedue if above not works
# How to Fix it:
#################
1. Remove wkhtmltopdf and related package
$ sudo apt-get remove libqt4-dev qt4-dev-tools wkhtmltopdf
$ sudo apt-get autoremove
2. Install requirement package for compiling
$ sudo apt-get install openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y
3. Clone from git wkhtmltopdf and qt source
$ git clone git://github.com/wkhtmltopdf/wkhtmltopdf.git wkhtmltopdf
$ mkdir qt-wkhtmltopdf && cd qt-wkhtmltopdf
$ git clone https://www.github.com/wkhtmltopdf/qt --depth 1 --branch wk_4.8.7 --single-branch .
4. Compile qt
$ sudo ./configure -nomake tools,examples,demos,docs,translations -opensource -prefix "`pwd`" `cat ../wkhtmltopdf/static_qt_conf_base ../wkhtmltopdf/static_qt_conf_linux | sed -re '/^#/ d' | tr '\n' ' '`
$ sudo make -j3
$ sudo make install
5. Compile wkhtmltopdf
$ cd ../wkhtmltopdf
$ sudo ../qt-wkhtmltopdf/bin/qmake
$ sudo make -j3
$ sudo make install
6. Reboot
$ sudo reboot
#http://www.grobak.net/id/blog/how-fix-wkhtmltopdf-failed-error-code-6
@joaomlopes
Copy link

Is this a solution to this error?

@danielschwaiger
Copy link

This solucion worked for me getting the same error i did the next steps :

I run the Ubuntu Server 16.04.2 LTS with odoo v8

  1. Remove wkhtmltopdf and related package
    $ sudo apt-get remove libqt4-dev qt4-dev-tools wkhtmltopdf

$ sudo apt-get autoremove

  1. Install this packages ( some of them may be in the last version installed allready on your server)
    $ sudo apt-get install openssl build-essential libssl-dev libxrender-dev git-core libx11-dev libxext-dev libfontconfig1-dev libfreetype6-dev fontconfig -y

  2. Download the wkhtmltox-0.12.1_linux-trusty-amd64.deb
    $ wget http://download.gna.org/wkhtmltopdf/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
    $ sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb

  3. Reboot the server, clean the cookies in your web browser and try it !

@victorcastro
Copy link

Great! Thanks krugerdawann

@Edtigoza
Copy link

Edtigoza commented Aug 3, 2017

I have migrated odoo 8 from ubuntu 14.04 LTS to debian 9 stable and have this same problem

This solucion worked for me getting the same error i did the next steps :

Remove wkhtmltopdf and related package

$ sudo apt-get remove libqt4-dev qt4-dev-tools wkhtmltopdf

$ sudo apt-get autoremove
go to https://wkhtmltopdf.org/downloads.html and download stable series
Install the requierements

Linux | 0.12.4 | 32-bit / 64-bit | depends on: zlib, fontconfig, freetype, X11 libs (libX11, libXext, libXrender) I use this option for debian 9,

$ sudo apt-get install fontconfig libfreetype6 zlib1g zlibc libx11-6 libx11-data libxext6 libxext-dev x11proto-xext-dev libxrender1 libxrender-dev

download tar.xz

$ wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

$ unxz wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

$ tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar

$ cd wkhtmltox/bin/

Make a simbolik link into the folder /usr/bin/

$ ln -s /path-to-folder/wkhtmltox/bin/wkhtmltopdf /usr/bin/wkhtmltopdf

$ ln -s /path-to-folder/wkhtmltox/bin/wkhtmltoimage /usr/bin/wkhtmltoimage

Restart odoo service

$ sudo service odoo restart or sudo systemctl restart odoo.service

after restart odoo server you can see in your log file that odoo takes the new source to the wkhtmltopdf ( your new instalation)

$ tail -f /var/log/odoo/odoo-server.log

clean the cookies in your web browser and try it !

@spreadred
Copy link

What about for Odoo 10.0? I followed the gist at the top, many errors were thrown during qt compilation, causing the entire process to fail. Any ideas?

@melroy89
Copy link

is really hope there is a better way then compiling from scratch...

@DenisShalaevSetronica
Copy link

Edtigoza, thanks!
I was helped by your advice.

@gordan-cuic
Copy link

Tnx @krugerdawann ... Really appreciated

@joshuapinter
Copy link

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:

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

@jay-sawant-pro
Copy link

thanks @joshuapinter, this worked for me.

@baiano
Copy link

baiano commented Feb 1, 2019

@joshuapinter you are the man.. o/
thanks

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