This brief tutorial shows students and new users how to install wkhtmltopdf and wkhtmltoimage on Ubuntu 18.04 | 16.04.
For the uninitiated, wkhtmltopdf and wkhtmltoimage are command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine.
In some cases, you’ll find these tools embedded in online applications and services to render HTML and PDF files for easy reporting and subscriptions. These tools run entirely “headless” and do not require a display or display service.
If you’re a student or new user looking for a Linux system to learn on, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.
Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other device.
While learning Ubuntu, you will find that Linux isn’t so different than Windows and other operating systems in so many ways, especially when it comes to using the system to get work done.
To install these tools on Ubuntu, follow the steps below:
Step 1: Install wkhtmltopdf & wkhtmltoimage
To install wkhtmltopdf and wkhtmltoimage in Ubuntu is as simply as running the apt command. However, then version that comes with Ubuntu might not necessarily be the latest.
To install the latest, you’ll want to download the .deb file from the project website.
At the time of this writing, the current stable series is 0.12.5, which was released on June 11, 2018.
Check the link below for the latest version has it becomes available:
First installed required packages if you don’t already have them:
sudo apt update sudo apt install wget xfonts-75dpi
Then run the commands below to download and install.
cd /tmp wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
If you run into trouble installing, simply follow the commands above with:
sudo apt -f install
After installing, you can verify that they’re installed by running the commands below:
That should output similar line as shown below:
wkhtmltopdf 0.12.5 (with patched qt)
Run the next command below:
Will output similar line as shown below
wkhtmltoimage 0.12.5 (with patched qt)
Step 2: Using wkhtmltopdf & wkhtmltoimage
wkhtmltopdf is able to put several objects into the output file, an object is either a single webpage, a cover webpage or a table of contents.
The syntax below is how to use wkhtmltopdf.
wkhtmltopdf source_file destination_file.pdf
For example, if you’d like to the example.com webpage into PDF, simply run the commands below
wkhtmltopdf https://example.com example.com.pdf
The web content will be generated into a PDF file.
For more about how to use the command, read this page:
This post showed you how to install wkhtmltopdf and wkhtmltoimage on Ubuntu 18.04 | 16.04. If you find any error above, please use the comment form below to report it.
You may also like the post below: