View .doc file with java applet

I have a web application. I created an MS Word document in XML format (Word 2003 XML Document) on the server side. I need to show this document to the user from the client side using some kind of viewer. So the question is, which libraries can I use to solve this problem? I need an API to view a Word document on the client side using java.

+5
source share
4 answers

You cannot reliably display a Word document on a web page using Java (or any other simple technology, for that matter). There are several commercial libraries for Word, but you will not find them easy, cheap or reliable solutions.

What you need to do is the following:

(1) Word .NET- (2) Rich Text Word (3) RTF Swing, HTML:

String rtf = [your document rich text];
BufferedReader input = new BufferedReader(new StringReader(rtf));

RTFEditorKit rtfKit = new RTFEditorKit();
StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
rtfEdtrKt.read( input, doc, 0 );
input.close();

HTMLEditorKit htmlKit = new HTMLEditorKit();       
StringWriter output = new StringWriter();
htmlKit.write( output, doc, 0, doc.getLength());

String html = output.toString();

, Word , . , , , .

+4

docx4all - Swing, Word 2007 XML (.. Word 2003 XML), .

svn.

. , , , HTML PDF? docx4j . (: "" ).

+1

Apache POI - Java API Microsoft Word, ( OLE2 OOXML, .doc .docx ).

doc :

import java.io.*;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;

public class ReadDocFile {
public static void main(String[] args) {
File file = null;
WordExtractor extractor = null ;
try {

file = new File("c:\\New.doc");
FileInputStream fis=new FileInputStream(file.getAbsolutePath());
HWPFDocument document=new HWPFDocument(fis);
extractor = new WordExtractor(document);
String [] fileData = extractor.getParagraphText();
for(int i=0;i<fileData.length;i++){
if(fileData[i] != null)
System.out.println(fileData[i]);
}
}
catch(Exception exep){}
}
}

: HWPF ( HWPF )

, POI:

HWPF .

+1

openoffice . java.

0
source

All Articles