Java - convert doc / docx file to chm file

I have an idea to convert Word document files (.doc / .docx) to a help file (.chm). I want to use Java to convert files. My formula is simple. To make the Table of Contents page and other links in a text document, as a package explorer or File Explorer, and make user navigation easier, faster and more convenient to navigate between pages of a document.

So my question is:

Are there any built-in libraries in java that can be imported and used to convert files?

Share your ideas to implement the above concept.

+6
source share
2 answers

This is a pretty difficult task to do in Java. But you can still do this if you install the Microsoft HTML Help Wizard.

  • First, you can extract the text of Word documents through the Apache POI , and then output them as HTML documents to a temporary directory.
  • Then you need to create an HHP file. It should be fairly easy to create, as it is a text file. Just follow the specifications below here
  • Then you should have the corresponding HHC file. 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, find the structure of the HHK file.

  • Once you are done, you can execute hhc.exe <inputfile.hhp> with Java. That should do the job.
+6
source

Not that I knew or what I could find. But instead, what about creating a java program that will do everything for you by manipulating the necessary software that you will use if you did it manually? just sending commands and do it for you. I would provide some code, but I did not do this in java.

An alternative would be to do this in VBscript, invoking certain java classes to run and using VBScript to send keystrokes to programs. The only drawback of this method would be that you could not run it in the background and could not use your computer until it was completed.

0
source

Source: https://habr.com/ru/post/914712/


All Articles