If you've worked in Windows long enough, you have come across the .chm file format. This format is nothing more than a compressed html directory with an included index for easy viewing.
Problem is, you can't view these files in Linux without the help of another tool. And sometimes you want to be able view these files in another format. Well, fortunately the Linux development community has solved that problem by creating various tools to manage these .chm files.
In this tutorial you are going to learn how to view .chm files and convert them to both html and pdf documents. This tutorial will be using the Ubuntu distribution, but this task can be tackled with just about any distribution available.
View chm files
Before we get into converting these files, let's see how to simply view them in Linux. Luckily there is a single, user-friendly tool for this task. The tool - Xchm. Xchm does one thing - view compiled html documents. This tool can display the contents tree (if one exists), allows you to navigate the document, change the fonts, and search the text.
To install this tool issue the following command:
sudo apt-get install xchm
Once installed, you can start the tool from the Office sub-menu of the Applications menu. When you start the tool up you should instantly notice how simple the interface is.
In Figure 1 Xchm is opened with a Microsoft TechNet document. As you can see, you can navigate around using any link included in the document as well as with the contents tree in the left pane.
But what if you want to edit that document or convert it to a pdf document? Simple - install two more applications.
Editing chm documents
In order to edit these documents you are going to need to convert them to html documents. This conversion is done with the CHMLIB tool. To install this issue the command:
sudo apt-get install libchm-bin
After this tool is installed you can make the conversions with a command like this:
extract_chmLib file.chm output_dir
Where file.chm is the chm file you want to convert and output_dir is the name of the directory you want to output the file to. Understand that the output_dir does not (nor should) already exist, because the command will create it for you.
When the command is issued all of the contents of the chm file will be extracted into the output_dir. From there you can go into the newly created directory and edit to your hearts content.
Converting to pdf
The next task is to convert the file to a pdf document. This is done with the help of the htmldoc application. First, install this with the command:
sudo apt-get install htmldoc
The html tool is a graphical tool that allows you to add as many html documents that you want and convert them all into a single pdf file. The user interface (see Figure 2) is very simple to use.
You can also deal with the various options in the other tabs, but generating a basic PDF from your html documents is fairly straight forward.
No longer do you have to miss out on reading those pesky chm files. Although most people have no need for such tasks, there are those of us who do need access to these documents, but don't (or can't) read them in their original format. Now you have the means to read them in either html or pdf format.Advertisement
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.