How to install wkhtmltopdf with patched qt?

57,252

Solution 1

You can install wkhtmltopdf with --disable-smart-shrinking option from wkhtmltopdf.

Download and Install it.

http://wkhtmltopdf.org/usage/wkhtmltopdf.txt

The Document say

wkhtmltopdf 0.12.2.1 (with patched qt)

and

--disable-smart-shrinking Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant

Solution 2

This straightforward solution (no need to install xvfb, neither compiling QT neither wkhtmltopdf) works like a charm on my Debian Jessie server :

cd mytmpfolder
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo mv wkhtmltox/bin/wkhtmlto* /usr/bin/
#create simple html test file
echo "<html><body>test</body></html>" >> test.html
#perform conversion
sudo wkhtmltopdf  --disable-smart-shrinking  --lowquality --enable-external-links --enable-internal-links test.html test.pdf

Solution 3

Steps to Install Version 0.12.3 on Ubuntu 16.04.

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

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.

Solution 4

Here are the simple steps to install the wkhtmltopdf 0.12.5 (with patched qt) using a shell script for Ubuntu 14.04, 15.04, 16.04, 18.04, and 20.04.

Step 1. create a shell file

cd /tmp && nano install_wkhtmltopdf.sh

Step 2. paste the below code

WKHTMLTOX_X64=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.trusty_amd64.deb
WKHTMLTOX_X32=https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.trusty_i386.deb

sudo apt-get install wget git python-pip gdebi -y

if [ "`getconf LONG_BIT`" == "64" ];then
  _url=$WKHTMLTOX_X64
else
  _url=$WKHTMLTOX_X32
fi
sudo wget $_url
sudo gdebi --n `basename $_url`
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin

Step 3. make the file executable

sudo chmod +x install_wkhtmltopdf.sh

Step 4. execute the shell script

./install_wkhtmltopdf.sh
Share:
57,252
hidechae
Author by

hidechae

Updated on July 09, 2022

Comments

  • hidechae
    hidechae almost 2 years

    I want to convert html to pdf, and I use wkhtmltopdf.

    But print size is smaller than I supposed. I want to try --disable-smart-shrinking option but error occured like

    $ xvfb-run -- /usr/bin/wkhtmltopdf --disable-smart-shrinking $INPUT $OUTPUT
    The switch --disable-smart-shrinking, is not support using unpatched qt, and will be ignored.Loading page (1/2)
    Printing pages (2/2)
    Done
    

    Maybe I have to install wkhtmltopdf with patched qt, but I don't know how to install.

    I saw following size, but gitorious.org doesn't work.

    wkhtmltopdf patched qt?

    My OS is Ubuntu14.04, and wkhtmltopdf version is 0.12.2.1

    If you know other reason to be printed smaller, tell me please. thanks.

  • Vlax
    Vlax over 7 years
    Verified solution for Ubuntu 16.04 LTS.
  • halfbit
    halfbit over 7 years
    also with 0.12.4 on debian
  • Raj
    Raj about 7 years
    Worked for me on UBUNTU 16
  • Raj
    Raj about 7 years
  • Pandora
    Pandora over 6 years
    Works like a charm on Debian Jessie with wkhtmltopdf version 0.12.4. Thank you!
  • sarfarazsajjad
    sarfarazsajjad over 6 years
    last command sudo wkhtmltopdf --disable-smart-shrinking --lowquality --enable-external-links --enable-internal-links test.html test.pdf gave error wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory
  • sarfarazsajjad
    sarfarazsajjad over 6 years
    I installed libxrender1 with sudo apt-get install libxrender1 now it give me error Error: Failed loading page http://test.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to network error: HostNotFoundError
  • Scott Stensland
    Scott Stensland about 6 years
    @Saifee page you mention test.html no longer exists however now even https pages work fine
  • Tsounabe
    Tsounabe about 6 years
    @Saifee Indeed you need a file to test its pdf conversion. I updated my answer.
  • user2588667
    user2588667 about 5 years
    Worked for me in a dockerfile on ubuntu 16.04. Thanks
  • Thierry Daguin
    Thierry Daguin over 4 years
    Still usefull (on CentOs 7) ! Thanks a lot !
  • kuvukala
    kuvukala about 3 years
    Worked for me Debian 9.0
  • Cedric Simon
    Cedric Simon almost 2 years
    You saved my weekend ;)