How to convert HTML to PDF with HTMLDoc on Debian 10

How to convert HTML to PDF with HTMLDoc on Debian 10

HTMLDOC is an open-source program that can be used to convert HTML and Markdown source files to PostScript and PDF files. There are two types of HTML files, 1) Structured documents with headings like, H1, H2, etc that is known as book and 2) unstructured documents without headings that are known as web pages.

In this tutorial, we are going to explain how to install HTMLDOC on Debian 10 and convert an HTML file to pdf.eval(ez_write_tag([[580,400],’howtoforge_com-medrectangle-3′,’ezslot_2′,121,’0′,’0′]));

Requirements

  • A server running Debian 10.
  • A root password is configured on your server.

Getting Started

First, update your system with the latest version by running the following command:

apt-get update -y
apt-get upgrade -y

Once your system is updated, restart it to apply the configuration changes.

Install HTMLDOC

By default, HTMLDOC is available in the Debian 10 default repository. You can install it by just running the following command:

apt-get install htmldoc -y

After installaing HTMLDOC, you can list all the options available with HTMLDOC with the following command:

htmldoc --help

Create Your First PDF from HTML

First, create a test.html file with the following command:

nano test.html

Add the following code:

<html>
<head>
    <title>This is my first PDF</title>
</head>
<body>
    This is the body of my first PDF.
</body>
</html>

Save and close the file, when you are finished.

Now, run the following command to converts test.html to test.pdf with the following command:eval(ez_write_tag([[580,400],’howtoforge_com-medrectangle-4′,’ezslot_1′,108,’0′,’0′]));

htmldoc --webpage -f test.pdf test.html

The above command will generate a new pdf file named test.pdf.

Congratulations! you have successfully installed HTMLDOC on Debian 10 server.

About the Author

Leave a Reply