如何打开和转换CHM文件?

我有一些.chm格式的文档。 我想知道在Ubuntu中是否有更容易导航,支持和文件大小相同的文件格式?

如果有,我想开始转换所有这些书,并且可能在我的所有Ubuntu PC和我的Android手机上使用它们而不那么麻烦。

您可以使用命令行程序chm2pdf将其转换为PDF( 在此处安装chm2pdf )。 安装完成后,您可以从终端运行命令,如下所示:

 chm2pdf --book in.chm out.pdf 

如果你不知道,有几个chm阅读器可用 – 只需在软件中心搜索chm

你也可以使用命令行工具7-Zip ( 在这里安装p7zip-full ) 将 chm文件解压缩到html:

 7z x file.chm 

如果您不想使用PDF,那么我建议使用相当好的开放式电子书格式Epub,您可以在Ubuntu上安装一个名为Caliber的好读者,Calibre有一个有用的转换工具,可以导入chm文件然后将它们转换为包含epub的其他格式。 在大多数智能手机和平板电脑上也可以轻松阅读epubs。

可以从软件中心安装Calibre。

如果您更喜欢KDE,还有KChmViewer。

Android上还有xchm和一些chm阅读器 。

葡萄酒就够了。

然后:使用此软打开它

在此处输入图像描述

dv3500ea有一个很棒的chm2pdf答案 ,但我更喜欢将它们作为html文件阅读。

简而言之:

 sudo apt-get install libchm-bin extract_chmLib myFile.chm outdir 

资料来源: http : //www.ubuntugeek.com/how-to-convert-chm-files-to-html-or-pdf-files.html

然后打开./outdir/index.html查看转换后的html文件! Yaaay! 好多了。 现在我可以像.chm文件一样导航它,但我也可以使用我的Chrome浏览器在页面上搜索文本,轻松打印等。

让我们创建一个名为chm2html的命令

这是我写的一个很好的剧本。

  1. 将以下脚本复制并粘贴到文件chm2html.py
  2. 使其可执行: chmod +x chm2html.py
  3. 如果你还没有,请创建一个~/bin目录: mkdir ~/bin
  4. ~/bin目录中创建chm2html.py的符号链接: ln -s ~/path/to/chm2html.py ~/bin/chm2html
  5. 注销Ubuntu然后重新登录,或者使用source ~/.bashrc重新加载路径
  6. 用它! chm2html myFile.chm 。 这会自动转换.chm文件并将.html文件放入名为./myFile的新文件夹中,然后创建一个名为./myFile_index.html的符号链接,指向./myFile/index.html

chm2html.py文件:

 #!/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) <= 1): print("Error: missing .chm file input parameter. \n" "Usage: `./chm2html.py fileName.chm`. \n" "Type `./chm2html -h` for help. `Exiting.") sys.exit() if (sys.argv[1]=="-h" or sys.argv[1]=="h" or sys.argv[1]=="help" or sys.argv[1]=="-help"): print("Usage: `./chm2html.py fileName.chm`. This will automatically convert the fileName.chm file to\n" ".html files by creating a directory named \"fileName\" right where you are, then it will also create a\n" "symbolic link in your current folder to ./fileName/index.html, with the symbolic link name being fileName_index.html") sys.exit() file = sys.argv[1] # Full input parameter (fileName.chm) name = file[:-4] # Just the fileName part, withOUT the extension extension = file[-4:] if (extension != ".chm"): print("Error: Input parameter must be a .chm file. Exiting.") sys.exit() # print(name) # DEBUGGING # Convert the .chm file to .html command = "extract_chmLib " + file + " " + name print("Command: " + command) os.system(command) # Make a symbolic link to ./name/index.html now pwd = os.getcwd() target = pwd + "/" + name + "/index.html" # print(target) # DEBUGGING # see if target exists if (os.path.isfile(target) == False): print("Error: \"" + target + "\" does not exist. Exiting.") sys.exit() # make link ln_command = "ln -s " + target + " " + name + "_index.html" print("Command: " + ln_command) os.system(ln_command) print("Operation completed successfully.") 
Interesting Posts