Convert CHM to PDF

How to convert CHM to PDF in Linux

1. Install dependencies by running the following command in the terminal:

sudo apt-get install htmldoc libchm-bin python-chm

2. Next, download chm2pdf by clicking here or using wget


3. Now extract the downloaded file.

tar -xzvf chm2pdf-0.9.1.tar.gz

4. Browse to the folder you extracted and run:

cd pdf-0.9.1
sudo python install

Now on the command line, type:

chm2pdf [options] input_filename [output_filename]

chm2pdf examples

Unstructured HTML files inside the CHM file, use of –webpage option – produces my-file.pdf:

chm2pdf --webpage my-file.chm

Structured HTML files:

chm2pdf --book my-file.chm

Structured HTML files, produce a table of contents page automatically (–title option):

chm2pdf --book --title my-file.chm

Structured HTML files, produce a table of contents page automatically (–title option), add a “titlepage” as found in the toc.html file inside the CHM:

chm2pdf --book --title --titlefile toc.html my-file.chm

If the file “toc.html” is not found, a warning will be issued and the option will be ignored – just browse the (very verbose) output of chm2pdf to see that warning if you suspect you mispelled the titlefile name.

Like above, now with an explicitly set page size and maximum compression level for the resulting PDF:

chm2pdf --book --title --titlefile toc.html --size 177.8×233.3mm --compression 9 my-file.chm

Like above, but name the PDF “your-file.pdf”:

chm2pdf --book --title --titlefile toc.html --size 177.8×233.3mm --compression 9 my-file.chm your-file.pdf

A very interesting option (and one that is not htmldoc-specific, but is pure chm2pdf-specific) is the –extract-only option:

chm2pdf --extract-only my-file.chm

will extract the contents of my-file.chm (all the HTML and other, “special”, files inside the CHM) into the directory CHM2PDF_TEMP_ORIG_DIR/my-file. Thus, if CHM2PDF_TEMP_ORIG_DIR has its default value “/tmp/chm2pdf/orig”, chm2pdf will extract the file into /tmp/chm2pdf/orig/my-file and stop.

You can then examine the extracted files at your pace. They will be overwritten next time you call chm2pdf with the same file(name).

If you want to know more available options use the following command from your terminal

chm2pdf --help


I am a g33k, Linux blogger, developer, student and Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.