How to install wkhtmltopdf with patched qt?
Asked Answered
M

8

51

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.

Marquise answered 27/12, 2015 at 9:8 Comment(3)
--disable-smart-shrinking option problem is resolve by install from wkhtmltopdf.org/downloads.html. But size problem is still occured.Marquise
I think you need a new question for the size problem. the size problem depends on HTML or wkhtmltopdf or other. so add more information to the new question.Regret
ok, I will make new question for the size problem. Install problem is resolbed, thanks.Marquise
R
12

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

Regret answered 30/12, 2015 at 1:50 Comment(0)
J
84

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
Jeffery answered 12/7, 2016 at 18:11 Comment(10)
Verified solution for Ubuntu 16.04 LTS.Lytle
also with 0.12.4 on debianPolystyrene
Worked for me on UBUNTU 16Abstriction
Updated Solution gist.github.com/Rajeshr34/2e9b2438ff142e51c729b4b9b772680aAbstriction
Works like a charm on Debian Jessie with wkhtmltopdf version 0.12.4. Thank you!Highness
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 directoryVoltaic
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: HostNotFoundErrorVoltaic
@Saifee page you mention test.html no longer exists however now even https pages work fineTetragon
@Saifee Indeed you need a file to test its pdf conversion. I updated my answer.Jeffery
Still usefull (on CentOs 7) ! Thanks a lot !Cardenas
R
39

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.

Roadside answered 14/11, 2017 at 22:35 Comment(2)
Worked for me in a dockerfile on ubuntu 16.04. ThanksKarli
Worked for me Debian 9.0Weedy
R
12

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

Regret answered 30/12, 2015 at 1:50 Comment(0)
H
11

The solution that @raj added in the comments worked for me in Ubuntu 22.04.3 LTS so I decided to include an updated answer here:

sudo apt-get install xfonts-75dpi
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt --fix-broken install
rm wkhtmltox_0.12.6.1-2.jammy_amd64.deb 

Then confirm that it installed the patched qt version:

wkhtmltopdf -V
=> wkhtmltopdf 0.12.6.1 (with patched qt)

Original gist from Raj.

https://gist.github.com/Rajeshr34/2e9b2438ff142e51c729b4b9b772680a

Harbert answered 2/10, 2023 at 21:48 Comment(0)
H
5

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
Hastie answered 22/10, 2020 at 13:31 Comment(1)
if you get "E: Package 'libpng12-0' has no installation candidate" be sure you install the proper package compatible to your distro. See here askubuntu.com/a/1371063/276370Barque
L
0

Updated solution posted by @cortex, not completly works for Debian 12.2. I reached problem with missing libjpeg-turbo8 without candidate to install via sudo apt-get install libjpeg-turbo8

To install that You need to do

wget http://mirrors.kernel.org/ubuntu/pool/main/libj/libjpeg-turbo/libjpeg-turbo8_2.1.2-0ubuntu1_amd64.deb
sudo apt install ./libjpeg-turbo8_2.1.2-0ubuntu1_amd64.deb
sudo apt-get install xfonts-75dpi
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
sudo apt --fix-broken install
rm wkhtmltox_0.12.6.1-2.jammy_amd64.deb

And after that i recieve wkhtmltopdf with patched qt (i need that to create pdf with flags --header-html and --footer-html. Default version from apt-get dosen't have this feature.

Lalita answered 17/11, 2023 at 7:26 Comment(0)
H
0

if the this solution doesn't work The solution that @raj added in the comments worked for me in Ubuntu 22.04.3 LTS so I decided to include an updated answer here:

  1. sudo apt-get install xfonts-75dpi

  2. wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb

  3. sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb

  4. sudo apt --fix-broken install

  5. rm wkhtmltox_0.12.6.1-2.jammy_amd64.deb Then confirm that it installed the patched qt version:

  6. wkhtmltopdf -V => wkhtmltopdf 0.12.6.1 (with patched qt) Original gist from Raj.

**Run this command first then the above commands

source ~/.profile or source ~/.bashrc

Heribertoheringer answered 24/6 at 15:16 Comment(1)
It looks like Contex already wrote out an answer based on Raj's comment and Gist.Lorollas
M
0

Newest Update:

A lot of the answers here are loopholes that require you to break your installations and are not addressing the real problem which is picking the correct installation package specifically for your linux distribution.

For version 0.12.6.1 (with patched qt) on Debian, Ubuntu, Arch Linux, Windows, macOS, AlmaLinux, CentOS, Amazon Linux and openSUSE Leap Operating Systems:

To select the correct package for your system (distro and release), go here.

For Older Versions of wkhtmltopdf:

The above link also has an archive link for older versions. It also have instructions for working with different library dependencies.

Installation Instructions for Debian/Ubuntu Based Distros:

If you need xfonts-75dpi install it like so:

sudo apt install xfonts-75dpi

Then simply install the deb package you downloaded from the link above like so:

sudo apt install <path/to/deb/pacakge.deb>

Check the version:

prompt> wkhtmltopdf -V
wkhtmltopdf 0.12.<version> (with patched qt)
Maite answered 9/7 at 21:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.