This article will guide you through how to install Wkhtmltopdf for Odoo.
The Wkhtmltopdf is an open-source utility that enables users to convert any given HTML page to a PDF document of an Image. It is an additional package that we can use with Odoo. It comes in handy when generating PDF reports
Step1: The Wkhtmltopdf package has a couple of dependencies that can be installed using the following commands.
sudo apt-get install libjpeg-turbo8 libjpeg-turbo8 libxrender1 xfonts-75dpi xfonts-base -y
sudo apt-get install fontconfig
sudo apt-get install -f
Step2: Since Wkhtmltopdf doesn’t have an official repository, let’s download it first from Github.
Ubuntu 20.04:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
For older Ubuntu versions you can download the package using the following commands.
Ubuntu 18.04:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
Ubuntu 16.04:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.xenial_amd64.deb
If you are using another OS such as CentOS, here are corresponding repositories for CentOS 7 & 8.
CentOS 8:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm
CentOS 7:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos7.x86_64.rpm
Step3: Then install the package using the following command.
Ubuntu 20.04:
sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
or
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
Ubuntu 18.04:
sudo apt install ./wkhtmltox_0.12.6-1.bionic_amd64.deb
Ubuntu 16.04:
sudo apt install ./wkhtmltox_0.12.6-1.xenial_amd64.deb
CentOS 8:
sudo dnf localinstall wkhtmltox-0.12.6-1.centos8.x86_64.rpm
CentOS 7:
sudo yum localinstall wkhtmltox-0.12.6-1.centos7.x86_64.rpm
Make sure to download the correct package based on the OS that you are running on.
Step4: Copy binary from ~/usr/local/bin to ~/usr/bin.
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin
or point to the installed packages using:
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
That is it then. We hope that it will be easier for you to get this done.