Install wkhtmltopdf & wkhtmltoimage AlmaLinux

Wkhtmltopdf is a powerful open-source command line tool for converting HTML documents into PDF files. It is based on the webkit engine, which is used by many popular browsers such as Safari and Chrome. Wkhtmltopdf can be used to generate high-quality PDFs from HTML documents, and it supports a wide range of features including page headers and footers, page margins, table of contents, and more.

Setting up wkhtmltopdf is relatively straightforward. The first step is to download the appropriate version of wkhtmltopdf for your operating system. Once you have downloaded the file, you will need to extract it to a directory on your computer.

Next, you will need to add the directory containing wkhtmltopdf to your system’s PATH environment variable. This will allow you to run wkhtmltopdf from any directory on your computer without having to specify its full path each time.

Once you have added the directory containing wkhtmltopdf to your PATH environment variable, you can test that it is working correctly by running the following command in a terminal window:

wkhtmltopdf --version

If everything has been set up correctly, this should output the version number of wkhtmltopdf that you have installed.

Finally, if you want to use wkhtmltopdf in a web application or script, you will need to make sure that it is accessible from within your web server’s environment. This may involve setting up an alias or symlink so that the web server can find the executable file for wkhtmltopdf when it needs it.

Once everything has been set up correctly, you should be able to use wkhtmltopdf in your projects with ease!

Step 1: Let's use wget tool for downloading. If not present, run the commands below to install it.

sudo yum -y install wget

There is a package especially for AlmaLinux but others report no issues using the CentO 7/8 packages. I say let's use AlmaLinux. View all packages here.

Use Putty or your fav:

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox-0.12.6.1-2.almalinux8.x86_64.rpm

Step 2: Install wkhtmltopdf & wkhtmltoimage on Rocky|AlmaLinux 8 Once the RPM file is available locally, we can install it using rpm or yum command:

sudo yum localinstall wkhtmltox-0.12.6.1-2.almalinux8.x86_64.rpm

or

sudo dnf install ./localinstall wkhtmltox-0.12.6.1-2.almalinux8.x86_64.rpm

After successful installation use the command line tools:

$ wkhtmltopdf --help
$ wkhtmltoimage --help

You can check version:

$ wkhtmltopdf --version
wkhtmltopdf 0.12.6 (with patched qt)

$ wkhtmltoimage --version
wkhtmltoimage 0.12.6 (with patched qt)

If the above is returned, you have successfully installed wkhtmltopdf & wkhtmltoimage tools.

NOTES:

1) On one VPS box something went wrong. To get it corrected we:

yum remove -y wkhtmltopdf
yum remove -y wkhtmltox

The repeat steps 1 and 2.

Visit the wktoPDF (wkhtmltopdf) project documentation page to learn more.

PHP Projects:

https://github.com/mikehaertl/phpwkhtmltopdf https://github.com/KnpLabs/snappy