It can be useful to directly create PDF documents from HTML files through the Linux command line.
HTMLDOC is a useful tool that does that. For using it in Debian based distros, first open Terminal and install it as follows (this example uses Linux Mint):
Once installed, it can be directly used from the Terminal.
To convert an existing HTML file to PDF, the syntax is:
It is essential to use the –webpage parameter because HTMLDOC will then see it as an unstructured document without headings. The other HTML format is the book format which has all the headings like H1, H2 and so on. For this use the –book parameter instead of –webpage.
Once the conversion is complete, the PDF file will be available in the current directory.
You can also directly convert web URLs to PDF with this tool. Simply replace the source HTML file with that of the URL address:
To set a user password that is required for opening the PDF file, add the –encryption and –user-password parameters. So the command will be:
Once converted, a password will be needed to unlock and view the PDF file.
HTMLDOC has other parameters too like changing colors, fonts, etc. All of these can be viewed with the –help parameter.
Other than that, you can also check the man pages link:
All done.