August 11, 2007 · General · Email This Post

Sponsored Link
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

Sponsored Link

Incoming search terms:

Related posts

29 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!

    [Reply]

  2. Kazymodo says:

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

    [Reply]

  3. miko says:

    Very useful post!!!
    Thanks!

    [Reply]

  4. Mike says:

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

    [Reply]

  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

    [Reply]

  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.

    [Reply]

    kiran Reply:

    Super it worked :)..Cheers

    [Reply]

    ally nambandi Reply:

    How do you convert a chm to pdf if one have open it with xhcm?

    [Reply]

  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!!!!

    [Reply]

  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)

    [Reply]

  9. M Jones says:

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

    [Reply]

  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 :(

    [Reply]

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

    [Reply]

  12. Doma says:

    Tried chm2pdf, worked beautifully without problem.

    [Reply]

  13. cobra the joker says:

    Very Nice post …very nice program ….thanx

    [Reply]

  14. Techie Eval says:

    I reckon chm2pdf should be named promiseware.The results you receive can be different to what you expect and its definitely there to be broken….

    It doesn’t cope well with long filenames. –continuous was the option that worked for me to finally create a pdf, but the formatting was TOTALLY messed up – one word per line. Not good for a book!!!

    Good thing I dual boot with Vista!!! Nice article, but maybe a lot has changed since it was written in ’07.

    [Reply]

  15. cobra-the-joker says:

    Thanks very much … i was really looking for something like that .

    [Reply]

  16. tangxinfa says:

    I tried chm2pdf, it looks like perfect!!!

    [Reply]

  17. robertsong says:

    hi, it’s really a nice tool.
    But in chm file, I can do global research,
    is there any way to do this work in html?
    Now the only method is use “index” and search.

    Best Regards,
    robert

    [Reply]

  18. saheel says:

    thanks a lot
    very very useful and workable solution…

    [Reply]

  19. bp says:

    chm2pdf works fine!

    [Reply]

  20. zones says:

    Awesome – chm2pdf worked like a charm for me

    [Reply]

  21. Jacko says:

    I tried both converters htmldoc and chm2pdf, unfortunately none of these worked. I have very large books and received the following error –

    ERR002: Error: no pages generated!
    exit value: 256

    [Reply]

  22. anuj says:

    thanks for the tip. I managed to generate the pdf.
    If possible please also include steps to use the htmldoc software

    [Reply]

  23. chm2pdf worked PERFECTLY!
    htmldoc gave me very bad results.
    thanks to the author for the post and to the other guys for the hints on comments.

    [Reply]

  24. Nobi says:

    Thank you so much!

    [Reply]

  25. moin says:

    you can view chm file by installing kchmviewer
    And you can install it by typing this command in command prompt (sudo apt-get install kchmviewer)
    I tried it, it is really osum.

    [Reply]

  26. leiqin says:

    Thank you very muth!

    [Reply]

  27. fred says:

    thank you very much!

    [Reply]

Leave a Reply