Linux News|Linux Install sidebyside windows|Ubuntu|Linux Help|Installing Apache and php from source

Thursday, August 30, 2012

Converting CHM to PDF in Linux

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 is 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.
In Debian or Ubuntu:

$ sudo apt-get install libchm-bin
$ 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. In other Linuxes, you can install it from source. First download the libchm source archive from the above website. I could not get the extract_chmLib utility to compile under the latest version 0.38, so I used version 0.35 instead.

$ tar xzf chmlib-0.35.tgz
$ cd chmlib-0.35/
$ ./configure
$ make
$ make install
$ make
After doing the 'make examples', you will have an executable extract_chmLib in your current directory. Here is an example of running the command with no arguments and the output it produces:
$ ./extract_chmLib                    usage: ./extract_chmLib 
After running the utility to extract the HTML files from your CHM file, the extracted files will appear in . There would not be an 'index.html' file, unfortunately. So you will have to inspect the filenames and/or their contents to find the appropriate main page or Table of Contents.
Now the HTML is yours to enjoy!

   I have learnt this from lots of available sites and main reference I have given below.



  1. Hi Tarun, I looked at your post in Linuxquestions.

    how to restore var directory after I deleted it,now cant run cmnds which involves apt utility as i have removed the /var structure completely and when rebooted after deleting i have no gui.

    I am facing the same problem.Could you help me in solving this?

    Thanks in advance

  2. hi,
    I think what you can do is run ubuntu with live cd or pendrive and copy the var directory to your root directory. I have never tried it but it seems it can resolve your problem.