简体   繁体   English

如何使用Java创建CHM文件?

[英]How to create CHM file using java?

I am planning to write a utility for me which will accept a directory having html files and then based on those html files it will create a CHM [Microsoft Compiled HTML Help] file. 我打算为我编写一个实用程序,该实用程序将接受包含html文件的目录,然后根据这些html文件创建一个CHM [Microsoft编译的HTML帮助]文件。
So is there any free library to create CHM file ? 那么,有没有免费的库可以创建CHM文件? If not then please mention some tutorial or links for basic understanding on how to create CHM file. 如果不是,请提及一些教程或链接,以获取有关如何创建CHM文件的基本知识。

The "easiest" way to create a CHM file is to use the "HTML Workshop" from Microsoft. 创建CHM文件的“最简单”方法是使用Microsoft的“ HTML Workshop”

Basically "HTML Workshop" is an .exe (hhc.exe) file, that compiles a given folder structure of HTML, CSS and JS into a single .chm file that is not editable anymore. 基本上,“ HTML Workshop”是一个.exe(hhc.exe)文件,它将给定的HTML,CSS和JS文件夹结构编译为一个不再可编辑的.chm文件。

So in your case where you want to build the .chm file within java, you need to save your HTML, JS and CSS sources into the correct structure for the hhc.exe (see the "HTML Workshop" documentation on about how that structure has to look like). 因此,如果您要在Java中构建.chm文件,则需要将HTML,JS和CSS源保存到hhc.exe的正确结构中(有关该结构的结构,请参见“ HTML Workshop”文档)看起来像)。

Once that is done, copy the hhc.exe from it's installation directory into your HTML source folder and run it. 完成后,将hhc.exe从其安装目录复制到HTML源文件夹中并运行它。 This can be achieved by calling a batch script from your java application, what can be achieved using the following code: 这可以通过从Java应用程序中调用批处理脚本来实现,可以使用以下代码实现:

Process p = Runtime.getRuntime().exec("host call mySuperCoolBatchScript.bat);
p.waitFor();

Once the compiling process is done, delete the previously copied hhc.exe file from your HTML source folder and done. 编译过程完成后,从HTML源文件夹中删除以前复制的hhc.exe文件并完成。

I hope that helps a bit, let me know if you have any questions. 希望能有所帮助,如果您有任何疑问,请告诉我。

From the reference of javadoc in chm format, Franck Allimant's site , there seems to exist two scripts for generating chm from javadoc : Franck Allimant的站点参考chm格式的javadoc来看,似乎存在两个用于从javadoc生成chm的脚本:

Although I'm not fond of the snake, I would advice you to use the Python script, as it may be more easy to insert in a build process (read in maven or ant) 尽管我不喜欢蛇,但我还是建议您使用Python脚本,因为在构建过程中插入它可能更容易(在maven或ant中阅读)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM