Question

I have an idea of converting Word document(.doc/.docx) files to Help file(.chm) format. I want to use Java for the conversion of files. My formula is simple. To make the Table of Contents page and other links in word document, as package explorer or File explorer and make the user navigation simpler, faster and easy to navigate among the pages in the document.

So, My Question is :

Are there any native libraries in java that can be imported and used for File Conversion?

Please share your ideas to implement the above concept.

Was it helpful?

Solution

Its a pretty difficult task to be done in Java. But you can still do it if you install Microsoft HTML Help Workshop.

  1. First you can extract the text of the Word documents via Apache POI and then output them as HTML documents to a temporary directory.
  2. Next you need to create a HHP file. It should be fairly easy to create as it is a text file. Just follow the specifications given here
  3. Then you should have a corresponding HHC file as well. Its a simple HTML document in the following format:

    <html>
    <head>
    </head>
    <body>
    <ul>
    <li><object type="text/sitemap">
    <param name="Name" value="Foo Directory">
    <param name="Local" value="BarDirectory/index.htm">
    <param name="ImageNumber" value="1">
    </object></li>
    <ul>
    <li><object type="text/sitemap">
    <param name="Name" value="Topic1">
    <param name="Local" value="BarDirectory/Bar.htm">
    <param name="ImageNumber" value="11">
    </object></li>
    <li><object type="text/sitemap">
    <param name="Name" value="Topic1">
    <param name="Local" value="BarDirectory/Foo.htm">
    <param name="ImageNumber" value="11">
    </object></li>
    </ul>
    </ul>
    </body>
    </html>
    

    Similarly look up the structure for a HHK file.

  4. Once you are done you can execute hhc.exe <inputfile.hhp> from Java. That should do the job.

OTHER TIPS

Not that I know of or that I could find. But instead, what about making a java program that does everything for you, manipulating needed software that you would be using if you were to do it manually? just sending the commands and have it do it for you. I would provide some code, but I haven't done this in java.

An alternative would be to do it in VBscript, calling certain java classes to run, and using VBScript to send keystrokes to the programs.The only downside to this method would be that you couldn't have it run in the background, and couldn't use your computer until it finished.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top