How to convert CHM file to PDF under CentOS

I have an ebook readerso I have been looking at a loot of ebooks lately. There are many free books out there I would have never taught about reading ever again, Sherlock Holmes being one of them. But one problem I am facing is that some books are in the CHM format, I have no idea who came up with this but now it seams sort of outdated and not used for this purpose any more. PDF has won the game. So how do I convert these CHM files to PDF so I can read them on my reader.

Step 1:
Use the program kchmviewer ($ yum install kchmviewer ) to extract the HTML from the CHM. CHM is just a nice wrapper for html with some images, so this is a fairly straight forward task.
Open the file with kchmviewer
Extract it by using the tool found under File -> Extract
Now you should have many HTML files and some images. This might already be enough for you reader but I prefer to have everything in one file and not have 100 of html files clogging everything. So the next task is to convert all these files into one coherent pdf file.

Step 2:
Use these htmldoc ($ yum install htmldoc) to generate a PDF.
Now the only thing you have to do is import all the html files and configure the output you want and you should get a pdf. This might not look 100% like the book but the text and images should be the same.

It is also possible to remove some chapters and modify some stuff. So if you know you are not going to read something you can just leave it out.

No comments: