Extract and decompile .chm file to view as html file under Linux

You can view .chm file using gnochm or kchmviewer under Linux. However sometime you cannot install these programs. There is a third alternative – arCHMage.

ADVERTISEMENTS

From the man page:
arCHMage is an extensible reader and decompiler for files in the CHM format. This is the format used by Microsoft HTML Help, and is also known as Compiled HTML. arCHMage is based on python-chm binding to chmlib from GnoCHM project.

It allows you extract .chm to directory.

Step # 1: Use apt-get command

If you are using Debian / Ubuntu, type the command:
# apt-get install archmage

Step # 2: Extract .chm to directory (directory will be created):

Type the command:
$ archmage file.chm output

Open your browser and type url file:///home/you/output or file:///home/you/output/index.html

Other usage

You can view chm file using inbuilt http-server.

View chm file using Webserver

You can run archmage as http-server, which will publish chm file contents on specified port:
# archmage -p 8888 /path/to/file.chm &

Open a browser and type ulr http://localhost:8888/ or http://server-ip:8888/

Force apache to publish chm files

You can force Apache to publish chm file contents if there is trailing slash in request to that file. First make sure you have working mod_python. Now open httpd.conf /apache2.conf file:
# vi httpd.conf

Add following lines to your httpd.conf:
AddHandler python-program .chm
PythonHandler archmod.mod_chm

Save and close the file. Restart apache.
# /etc/init.d/httpd restart

Now upload file.chm to document root of your Apache webserver. Now view file by typing URL: http://you.com/file.chm/

Note: trailing slash at the end of URL.

Download arCHMage

=> Download arCHMage

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
5 comments… add one
  • Binny V A Jan 23, 2007 @ 2:47

    If possible try to use a CHM view rather than viewing it this way. In most viewers, you can search through the text – which is the main advantage of CHM files.

  • unni kartha Oct 14, 2009 @ 16:09

    gnochm works fine for me. debian lenny gnu/linux

  • sh!zeeg Nov 14, 2009 @ 15:16

    Yay! Cool! Now I can read my CHMs in plaintext tty too! Elinks, lynx, w3m, conkeror. In any of my favorite browsers!
    Thank you very much.

  • noah Sep 14, 2011 @ 23:00

    RewriteRule ^(.*.chm)$ $1/ [R]

    Adds the trailing slash automatically

  • JorgeR3 Oct 30, 2011 @ 4:11

    Me da este error.

    Traceback (most recent call last):
    File “/usr/bin/archmage”, line 169, in
    main()
    File “/usr/bin/archmage”, line 165, in main
    source.extract(options.output)
    File “/usr/lib/pymodules/python2.7/archmod/CHM.py”, line 234, in extract
    self.process_templates(destdir=destdir)
    File “/usr/lib/pymodules/python2.7/archmod/CHM.py”, line 193, in process_templates
    open(os.path.join(destdir, os.path.basename(template)), ‘w’).write(self.get_template(template))
    File “/usr/lib/pymodules/python2.7/archmod/CHM.py”, line 188, in get_template
    return re.sub(”, self.sub_mytag, tpl)
    File “/usr/lib/python2.7/re.py”, line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
    File “/usr/lib/pymodules/python2.7/archmod/CHM.py”, line 179, in sub_mytag
    res = eval(re.group(1))
    File “”, line 1, in
    NameError: name ‘deftopic’ is not defined

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.

Next post:

Previous post: