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.


  • 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.


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:

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

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:

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.

Share this page:

1 Comment(s)