How to open and convert CHM documents?
I have some documents that are in a .chm format. I wondered if there is a file format that can be easier to navigate, supported and of equal file size in Ubuntu? If there is, I would like to start converting all those books and probably using them with less hassle on all my Ubuntu PCs and my Android phone.
8 Answers 8
You can convert them to PDF using the command line program chm2pdf (install chm2pdf here). Once installed you can run the command from a terminal like this:
chm2pdf --book in.chm out.pdf
In case you didn’t know, there are several chm readers available — just search chm in the Software Centre.
You can also extract chm files to html using the command line tool 7-Zip (install p7zip-full here):
If you do not want to use PDF then I would suggest Epub, a fairly good, open e-book format, you can install a good reader for it called Calibre on Ubuntu, Calibre has a useful conversion facility that can import chm files and then convert them to other formats epub included. epubs can be easily read on most smart phones and tablets as well.
Calibre can be installed from the software center.
There is also KChmViewer, if you prefer KDE.
KChmViewer is Ok. but I’d prefer the firefox addon [CHM Reader]. Not a good solution for my issue, as I want to get rid of those lousy chm files I already have to a better supported format. Pdf isn’t good either. Options?
This is an old question, but a straight-forward answer is to use archmage which can host the chm contents as a website on localhost.
and open http://localhost:5000 in your webbrowser to open the documentation inside the chm file.
Calibre will do it all
- Install Calibre
- import the chm file into Calibre with Add books button
- use Convert books button to convert it to epub or pdf.
This is ultimately what worked for me. On the command line, calibre can be installed with apt and used as ebook-convert to convert the CHM to a PDF.
dv3500ea has a great chm2pdf answer, but I prefer to read them as html files.
In short:
sudo apt-get install libchm-bin extract_chmLib myFile.chm outdir
Then open up ./outdir/index.html to view the converted html files! Yaaay! Much better. Now I can navigate it just like a .chm file, but I can also use my Chrome browser to search the pages for text, easily print, etc.
Let’s make a command called chm2html
Here’s a nice script I wrote.
- Copy and paste the below script into a file chm2html.py
- Make it executable: chmod +x chm2html.py
- Create a ~/bin directory if you don’t already have one: mkdir ~/bin
- Make a symlink to chm2html.py in your ~/bin directory: ln -s ~/path/to/chm2html.py ~/bin/chm2html
- Log out of Ubuntu then log back in, or reload your paths with source ~/.bashrc
- Use it! chm2html myFile.chm . This automatically converts the .chm file and places the .html files into a new folder called ./myFile , then it creates a symlink called ./myFile_index.html which points to ./myFile/index.html .
chm2html.py file: get the latest version of this file on GitHub here from my eRCaGuy_dotfiles repo:
#!/usr/bin/python3 """ chm2html.py - convert .chm files to .html, using the command shown here, with a few extra features (folder names, shortcuts, etc): http://www.ubuntugeek.com/how-to-convert-chm-files-to-html-or-pdf-files.html - (this is my first ever python shell script to be used as a bash replacement) Gabriel Staples www.ElectricRCAircraftGuy.com Written: 2 Apr. 2018 Updated: 2 Apr. 2018 References: - http://www.ubuntugeek.com/how-to-convert-chm-files-to-html-or-pdf-files.html - format: `extract_chmLib book.chm outdir` - http://www.linuxjournal.com/content/python-scripts-replacement-bash-utility-scripts - http://www.pythonforbeginners.com/system/python-sys-argv USAGE/Python command format: `./chm2html.py fileName.chm` - make a symbolic link to this target in ~/bin: `ln -s ~/GS/dev/shell_scripts-Linux/chm2html/chm2html.py ~/bin/chm2html` - Now you can call `chm2html file.chm` - This will automatically convert the fileName.chm file to .html files by creating a fileName directory where you are, then it will also create a symbolic link right there to ./fileName/index.html, with the symbolic link name being fileName_index.html """ import sys, os if __name__ == "__main__": # print("argument = " + sys.argv[1]); # print 1st argument; DEBUGGING # print(len(sys.argv)) # DEBUGGING # get file name from input parameter if (len(sys.argv)
How to open CHM files in Linux
Perhaps the best option, in case Firefox is your favorite web browser, is to try CHMFox, an extension to view CHM files directly from Firefox.
xchm
Xchm is a cross-platform client that supports all UNIX systems (Linux, * BSD, Solaris), Mac OS X and Windows.
Installation in Ubuntu and derivatives:
kchmviewer
Kchmviewer is the client to view CHM files that comes by default with KDE. It has not received updates for a while but it is fully functional.
Installation in Ubuntu and derivatives:
Okular
Okular, the default document viewer in KDE also includes support for CHM files, but this requires installing libchm libraries.
On Ubuntu and derivatives:
ChmSee
ChmSee is based on CHMLIB and uses GTK + for its implementation. Because it uses the Gecko rendering engine (yes, the same one that Firefox uses), ChmSee supports HTML and CSS perfectly.
Installation in Ubuntu and derivatives:
Final words
Finally, if you are a true geek, you can unzip the CHM file and navigate the HTML pages manually. This is possible because the .chm file consists of an index, a table of contents, and a set of HTML pages hyperlinked to the table, which are compressed to generate the help file.
That said, I believe that this format, in addition to being proprietary and obsolete (Microsoft itself abandoned its use), can be replaced by other equally valid and functional free alternatives (PDF, DJVU, etc.). Also, do not forget that Compiled HTML Help Files can contain web pages with malicious code, thus posing a security threat.
The content of the article adheres to our principles of editorial ethics. To report an error click here.
Full path to article: From Linux » FileLet's UseLinux » How to open CHM files in Linux
Как открыть файлы CHM в Linux
Возможно, лучший вариант, если Firefox - ваш любимый веб-браузер, - это попробовать CHMFox, расширение для просмотра файлов CHM прямо из Firefox.
XCHM
Xchm - это кроссплатформенный клиент, поддерживающий все системы UNIX (Linux, * BSD, Solaris), Mac OS X и Windows.
Установка в Ubuntu и производных:
kchmviewer
Kchmviewer - это клиент для просмотра файлов CHM, который по умолчанию поставляется с KDE. Некоторое время он не получал обновлений, но полностью работоспособен.
Установка в Ubuntu и производных:
Okular
Okular, программа просмотра документов, которая по умолчанию входит в KDE, также включает поддержку файлов CHM, но для этого необходимо установить библиотеки libchm.
ChmSee
ChmSee основан на CHMLIB и использует GTK + для своей реализации. Поскольку он использует движок рендеринга Gecko (да, тот же, что использует Firefox), ChmSee отлично поддерживает HTML и CSS.
Установка в Ubuntu и производных:
Заключительные слова
Наконец, если вы настоящий компьютерщик, вы можете распаковать файл CHM и перемещаться по HTML-страницам вручную. Это возможно, потому что файл .chm состоит из индекса, оглавления и набора HTML-страниц, связанных гиперссылками на таблицу, которые сжимаются для создания файла справки.
Тем не менее, я считаю, что этот формат, помимо того, что он проприетарный и устаревший (сама Microsoft отказалась от его использования), может быть заменен другими равноценными и функциональными бесплатными альтернативами (PDF, DJVU и т. Д.). Также не забывайте, что скомпилированные файлы справки HTML могут содержать веб-страницы с вредоносным кодом, что создает угрозу безопасности.
Содержание статьи соответствует нашим принципам редакционная этика. Чтобы сообщить об ошибке, нажмите здесь.
Полный путь к статье: Из Linux » ФайлДавайте использовать Linux » Как открыть файлы CHM в Linux