How to Convert chm files to HTML or PDF files
Sponsored Link
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
Wow—I used extract_chmlib on a 19.9MB 1000+ page .chm file and it converted the whole thing in 1.375s!
Great post, I have learned something usefull tonite!
Thank you.
Very useful post!!!
Thanks!
Awesome to know about but how do you make sure it produces a pdf with proper page ordering?
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
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.
I tried both, htmldoc & chm2pdf…. both work fine,
but quality of the output file of chm2pdf seems better than that of htmldoc!!!!
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)
i tried chm2pdf as suggested but it didn’t work, any suggestions?
TypeError: cannot concatenate ‘str’ and ‘NoneType’ objects
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 🙁
By using chm2pdf, i managed to convert it to pdf. But i also get error “exit value: 45056”, not sure what it is about…..
Tried chm2pdf, worked beautifully without problem.
Very Nice post …very nice program ….thanx
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.
Thanks very much … i was really looking for something like that .
I tried chm2pdf, it looks like perfect!!!
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
thanks a lot
very very useful and workable solution…
chm2pdf works fine!
Awesome – chm2pdf worked like a charm for me
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
thanks for the tip. I managed to generate the pdf.
If possible please also include steps to use the htmldoc software
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.
Thank you so much!
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.
Super it worked :)..Cheers
How do you convert a chm to pdf if one have open it with xhcm?
Thank you very muth!
thank you very much!