How to Install wkhtmltopdf and wkhtmltoimage on Ubuntu 20.04, 18.04, and 16.04
A step-by-step guide on installing wkhtmltopdf and wkhtmltoimage on various Ubuntu versions

Introduction to wkhtmltopdf and wkhtmltoimage
wkhtmltopdf and wkhtmltoimage are open-source command-line tools used to convert HTML documents to PDF and image formats, respectively. These tools are particularly useful for generating reports, invoices, and other documents from web-based content. In this article, we will walk through the process of installing wkhtmltopdf and wkhtmltoimage on Ubuntu 20.04, 18.04, and 16.04.
Prerequisites
Before proceeding with the installation, ensure you have:
- An Ubuntu system (20.04, 18.04, or 16.04)
- Access to a terminal or command line
- wget installed for downloading the necessary packages
Installing wkhtmltopdf and wkhtmltoimage
The installation process involves downloading the appropriate .deb package for your Ubuntu version and then installing it using apt.
For Ubuntu 20.04 and Later
- Download the .deb package using wget:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb- Install the downloaded package:
sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.debFor Ubuntu 18.04
- Download the .deb package:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb- Install the package:
sudo apt install ./wkhtmltox_0.12.6-1.bionic_amd64.debFor Ubuntu 16.04
- Download the .deb package:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.xenial_amd64.deb- Install the package:
sudo apt install ./wkhtmltox_0.12.6-1.xenial_amd64.debVerifying the Installation
After installation, you can verify that wkhtmltopdf is working correctly by checking its version:
wkhtmltopdf --versionThe output should be similar to:
wkhtmltopdf 0.12.6 (with patched qt)Testing wkhtmltopdf
To test wkhtmltopdf, you can convert a webpage to a PDF file:
wkhtmltopdf https://google.com google.pdfThis command will generate a PDF file named 'google.pdf' in your current directory, containing the content of the Google homepage.
Conclusion
In this guide, we have successfully installed wkhtmltopdf and wkhtmltoimage on Ubuntu 20.04, 18.04, and 16.04. These tools are invaluable for converting web content into PDF and image formats, making them ideal for various applications such as report generation and document creation. If you have any questions or need further assistance, feel free to comment below.
Tags
Comments (0)
Leave a Comment
No comments yet. Be the first to share your thoughts!