Simple CHM to PDF conversion on Linux

Posted on 07.01.2010 by Kim N. Lesmer.

This is nothing new, but if you ever needed a simple way to convert a document from CHM format into PDF format on Linux, here's an easy way to do it with a fairly good result. You need to make sure that chmlib and htmldoc is installed.

On Debian you can get them with:

# apt-get install libchm-bin htmldoc

Next, extract the contents from the CHM file:

$ extract_chmlib doc.chm DEST_DIR

Where DEST_DIR is the destination directory. If the directory doesn't exist, it will be created.

In order to create a single PDF file of A4 size you can use the following command:

$ htmldoc --size a4 --webpage -f doc.pdf DEST_DIR/*.html

That's it.