Page 1 of 1

How to Convert Doc or Docx File to HTML in java?

Posted: Wed Feb 01, 2012 4:57 pm
by abcdef
How to Convert Doc or Docx File to HTML in java? Please show me code

Re: How to Convert Doc or Docx File to HTML in java?

Posted: Wed Feb 01, 2012 11:47 pm
by rudolfo
.doc and .docx are Microsoft formats. Traditionally Microsoft doesn't play well with Java. Why do you need this to be done in Java? Your chances are better if you approach this in .NET. And yes, the first address to ask about proprietary formats of a specific owner is the owner of these formats, so that would be Microsoft again.

Re: How to Convert Doc or Docx File to HTML in java?

Posted: Wed Feb 01, 2012 11:58 pm
by Villeroy

Re: How to Convert Doc or Docx File to HTML in java?

Posted: Thu Feb 02, 2012 8:19 pm
by rudolfo
If the quality of the documentation is an indication for the quality of the implementation it might be better to avoid it: The dummy text "Description of the method" is everywhere in the Javadoc and for the class DOC2HTML itself the explanation is: "uses the api to present the contents excel 97 spreadsheet as an html file". Assuming that DOC is saying something about the file extension, the class should rather look into Word documents but not into spreadsheets.

Re: How to Convert Doc or Docx File to HTML in java?

Posted: Fri Feb 03, 2012 8:42 pm
by rudolfo
It seems like those who are responsable for the code are cheating a bit. Look at these 3 lines of code taken from the convertDOCToHTML() method:

Code: Select all

 PrintWriter outw = new PrintWriter(new FileWriter(file2));
 NativeExec.execute("antiword " + file1.getAbsolutePath(), outw);
 outw.close();
antiword might be not too bad in converting MS Word files, but you surely don't need several hundred lines of java code to build a wrapper around it.

Re: How to Convert Doc or Docx File to HTML in java?

Posted: Fri Feb 03, 2012 8:51 pm
by Villeroy
Sorry. I just posted the first google hit for "doc2html +java".

Re: How to Convert Doc or Docx File to HTML in java?

Posted: Fri Feb 03, 2012 10:06 pm
by rudolfo
No problem with me. The real problem is that we as Volunteers have too often use our time for a google lookup, which could as well be done by the OP. And surely we have better things to do then classifying the quality of what pops up at google. Unfortunately we are not living in a perfect world.