Friday, November 10, 2006

chm to pdf

CHM - Microsoft Compressed HTML Help - is a proprietary format for online help files, developed by Microsoft. Viewing CHM files using other operating systems is sometimes a little bit difficult.
Recently a CHM plug-in appeared for firefox which should be some help.
Sometimes it is still necessary to convert CHM files into other formats. While there are quite a lot of applications which could do that easily on Windows, it is still tricky for non-Windows systems.

e.g. for Mac OS X or other UNIX based OS

First you have to unpack the html files.
  1. Download the chmtools package.
  2. Unzip it: tar -zxf chmtools.tar.gz
  3. Go to the chmtools folder: cd chmtools
  4. Compile it: make
  5. Move the new command somewhere you can easily access it (you might have to become root to be able to do that), eg: su; cp chmdump /usr/bin
Step 1. to 5. you have to do only once.
  1. Now it is time to unpack the CHM file, eg: chmdump file.chm newFolder
Now we have to install two software packages which will do the actual html to pdf conversion.
  1. Download the fltk source (should be version 1.1 or above)
  2. Unzip it, eg: tar -yxf fltk-1.1.7-source.tar.bz2
  3. Go to the fltk folder, eg: cd fltk-1.1.7
  4. Compile it: make
  5. It could be you need to configure the compile process for your system - have a look at their manual.
  6. Install the new commands (you have to become root to be able to do that), eg: su; make install
  7. Download the htmldoc source
  8. Unzip it, eg: tar -yxf htmldoc-1.8.27-source.tar.bz2
  9. Go to the fltk folder, eg: cd htmldoc-1.8.27
  10. Compile it: make
  11. It could be you need to configure the compile process for your system - have a look at their manual.
  12. Install the new commands (you have to become root to be able to do that), eg: su; make install
Step 7. to 18. you have to do only once.
  1. Now look for the html files in the folder chmdump created.
  2. Go there, eg: cd newFolder
  3. Now you have to create a batch file containing all the html files you want to have in your pdf. Eg: ls *.thml > test.book
  4. Sometimes the files are not in the order you like. Use your favorite text editor to adjust that.
  5. Add the following two lines at the top of test.book to adjust the layout the pdf. The given format is best if you want to use the pdf file on your iLiad reader.
#HTMLDOC
-t pdf --webpage --size 12x15cm --pscommands --gray --jpeg -f test.pdf
  1. Run the batch file: htmldoc --batch test.book
  2. The result should be a pdf file called test.pdf.
Have fun

No comments: