简体   繁体   中英

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.
So is there any free library to create CHM file ? If not then please mention some tutorial or links for basic understanding on how to create CHM file.

The "easiest" way to create a CHM file is to use the "HTML Workshop" from Microsoft.

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.

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).

Once that is done, copy the hhc.exe from it's installation directory into your HTML source folder and run it. This can be achieved by calling a batch script from your java application, what can be achieved using the following code:

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.

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 :

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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