▷ How to convert HTML to PDF on Linux 【STEP BY STEP】⭐️

If we find ourselves in need of convert html to pdf in linuxwe have an excellent tool that can be used from a graphical interface: HTMLDOC.

How to Convert HTML to PDF on Linux

One of the easiest ways to convert html to pdf in linux is to install the “HTMLDOC” program. It’s a small utility that works with a range of file formats, including: HTML, PDF, Markdown, EPUB, PostScript.

HTMLDOC reads HTML and Markdown files and can convert them to PDF on Linux, Windows and Mac OS. Therefore, knowing how it works will also help us when we are not using our Linux distribution and need to use another system.

To start, we will first install —if we haven’t installed it— the “Synaptic” package. We open the terminal and write there:

sudo apt install synaptic

Once Synaptic is installed, we will open it, from the terminal we only have to type: sudo synaptic (you need root permissions). Or we can open it from the software center; what we like the most.

In Synaptic, we will click on “Search” (it’s at the top right of the window). We write the name of the program we want to install: htmldoc, and press “Enter” to start the search. When found, a list similar to the following image appears:

install htmldoc with synaptic
install htmldoc with synaptic

The next step is to check “htmldoc” so that it searches for all the dependencies necessary for the complete installation of the program. We accept the dependencies it suggests, then at the top of Synaptic we click on the “Apply” button to start installing the HTMLDOC software.

If we’re done with Synaptic, we’ll close it and launch HTMLDOC. The easiest way is to search for it among the installed applications. When we open this software, we will have an appearance similar to this image:

HTMLDOC frontend

For convert html to pdf in linux using HTMLDOC, we must first click on the “Input” tab at the top. We will choose an HTML file —we can also use several files as long as they are of the same format—, for this we will choose the “Add files” button. There is also the possibility of using URLs extracted from websites.

Then we must click on “Output” to define the PDF format and the name that we want to assign to the final file.

As a next step, it is strongly recommended to check in the “Fonts” tab that the “Character set” option is set to “UTF-8”. If not, we click on the defined character type and look for UTF-8 in the drop-down list. This ensures that words with accents and ñ will be displayed correctly in the final PDF document.

And now, if we are satisfied with all the steps, we must click on “Generate”. This starts the HTML to PDF conversion.

When the new PDF document has been generated, we can now save the settings used by the program, and for this we must click on the “Save” button. It will ask you for the location of the file. If we choose the “Book” format for the final PDF document, the name of the configuration file will end with .book.

We save it and we will have everything ready to enjoy our PDF document created from an HTML file.

If you prefer to use the Terminal to do this type of work, HTMLDOC offers the possibility of using the command line. You can check out the official HTMLDOC website where there is documentation to do this; Click on the “Documentation” button to access the subject that interests you.

Do you have any questions for us about what we have seen in this article? Feel free to contact us through the comments section. We will help you with pleasure.