August 11, 2007 · General · Email This Post

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Microsoft Compiled HTML Help is a proprietary format for online help files, developed by Microsoft and first released in 1997 as a successor to the Microsoft WinHelp format. It was first introduced with the release of Windows 98, and is still supported and distributed through Windows XP platforms.

HTML Help files are made with help authoring tools. Microsoft ships the HTML Help Workshop with supported versions of Microsoft Windows and makes the tool available for free download. There are also a lot of third-party help authoring tools available.

CHM files, known as Microsoft Compressed HTML Help files, are a common format for eBooks and online documentation. They are basically a collection of HTML files stored in a compressed archive with the added benefit of an index.

Under Linux, you can view a CHM file with the xchm viewer. But sometimes that’s not enough. Suppose you want to edit, republish, or convert the CHM file into another format such as the Plucker eBook format for viewing on your Palm. To do so, you first need to extract the original HTML files from the CHM archive.

This can be done with the CHMLIB (CHM library) and its included helper application extract_chmLib.

Install Chmlib in Ubuntu

sudo apt-get install libchm-bin

Convert .chm files in to HTML files

If you want to convert .chm files in to HTML files use the following command

extract_chmLib book.chm outdir

where book.chm is the path to your CHM file and outdir is a new directory that will be created to contain the HTML extracted from the CHM file.

Convert .chm files in to PDF files

First you need to install htmldoc. HTML processor that generates indexed HTML, PS, and PDF.HTMLDOC is a program for writing documentation in HTML and producing indexed HTML, PostScript, or PDF output (with tables of contents). It supports most HTML 3.2 and some HTML 4.0 syntax, as well as GIF, JPEG, and PNG images.

sudo apt-get install htmldoc

If you want to use htmldoc type the following command in terminal

htmldoc

Once it opens you should see similar to the following screen here you can choose the html file and convert them to pdf,ps

  • Share/Save/Bookmark

Related Articles

13 Comments to “How to Convert chm files to HTML or PDF files”

  1. Angus77 says:

    Wow—I used extract_chmlib on a 19.9MB 1000+ page .chm file and it converted the whole thing in 1.375s!

  2. Kazymodo says:

    Great post, I have learned something usefull tonite!
    Thank you.

  3. miko says:

    Very useful post!!!
    Thanks!

  4. Mike says:

    Awesome to know about but how do you make sure it produces a pdf with proper page ordering?

  5. Robert says:

    I tried chmlib/htmldoc with disappointing results. Then I found out about the chm2pdf utility and it is found in the Ubuntu repository. This is a command line utility but it works well, no muss or fuss.

    sudo apt-get install chm2pdf
    chm2pdf –book filename.chm filename.pdf

  6. Robert says:

    BTW, I also found out that there are chm readers for Ubuntu. I tried out a couple including xCHM which I think was the best (gnnochm would close unexpectedly).

    sudo apt-get install xchm

    Then find it in your menu->Applications->Accessories->xCHM

    or command line: xchm

    I prefer to convert them to pdf though.

  7. Vishal Mudnur says:

    I tried both, htmldoc & chm2pdf…. both work fine,
    but quality of the output file of chm2pdf seems better than that of htmldoc!!!!

  8. Satish Sharma says:

    I tried both on a “newer” chm file.
    Both barf differently.
    htmldoc fails totally, chm2pdf converts but the index/TOC is useless and it complained about some image formats in the file (jpg)

    I think all of these are poor tools for a very poor format (chm)

  9. M Jones says:

    i tried chm2pdf as suggested but it didn’t work, any suggestions?
    TypeError: cannot concatenate ’str’ and ‘NoneType’ objects

  10. I tried HTMLDOC, and it was apparently unable to convert any (I tried several different files) .chm files, kept reporting that it was unable to parse :(

  11. 4d result says:

    By using chm2pdf, i managed to convert it to pdf. But i also get error “exit value: 45056″, not sure what it is about…..

  12. Doma says:

    Tried chm2pdf, worked beautifully without problem.

  13. cobra the joker says:

    Very Nice post …very nice program ….thanx

Leave a Reply