6

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.

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
  • 2
    It sounds like a good idea, but extremely hard in practice. Converting DOC to anything is pretty hard, DOCX less so but still a big job. Since you are working in the Java realm, you might want to find a help format which works on all platforms (chm is just for Windows). – Paul Jowett May 10 '12 at 08:08
  • 1
    @jowierun yes, i know chm is only for windows.. – Avadhani Y May 14 '12 at 11:47
  • 2
    Apache POi has [support for reading and writing doc files](https://poi.apache.org/hwpf/index.html). – oers May 30 '12 at 12:34
  • @oers Can I use that Apachi PoI in Eclipse as a plugin or jar file....? Do i need to purchase Licence? – Avadhani Y May 30 '12 at 14:25
  • It is a set of jar files, just a java library. It is open source under the (free) apache license. – oers May 30 '12 at 14:27
  • Ok thanks. CAn you provide me the path to download that? – Avadhani Y May 30 '12 at 14:28
  • You'll have to checkout using SVN, it's still experimental. – NoBugs Jun 01 '12 at 19:57
  • Looks like there's already something to download: https://poi.apache.org/download.html#POI-3.8 – Alexander Pavlov Jun 05 '12 at 15:16
  • Finally, i didnt get perfect idea/solution which answers my question.... Hope some one will answer this question at some time.....:( anyway thanks for @Sankha Narayan Guria for sharing his idea.... – Avadhani Y Jun 08 '12 at 12:54

2 Answers2

6

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.
Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
  • @Avadhani Yes I understand. But using the HTML Help Compiler seems to be the only way possible to get the final CHM file because CHM is pure Windows proprietary format. – Sankha Narayan Guria May 31 '12 at 06:17
0

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.

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
Azulflame
  • 1,534
  • 2
  • 15
  • 30