I'm willing to use JODConverter
with ByteArrayStream
by using the following method.
public void convert(InputStream in,
DocumentFormat df,
OutputStream out,
DocumentFormat df1).
The problem is i don't know how create a working DocumentFormat
; what i want is the parameters for .doc(Microsoft Word 2003) and XHTML.
I found something like this but it won't work( I'm using JODConverter 2.2 with OpenOffice 4.0 running on headless mode).
DocumentFormat doc = new DocumentFormat("Microsoft Word",
"doc",
"application/msword");
DocumentFormat html = new DocumentFormat("HTML",
"html",
"text/html");
it throws the : java.lang.IllegalArgumentException: unsupported input format: Microsoft Word
I have found a solution for this, this is how you implement a DocumentFormat
in JODConverter
2.2 for .html
and .doc
:
//for HTML documents.
DocumentFormat html = new DocumentFormat("HTML", DocumentFamily.TEXT, "text/html", "html");
html.setExportFilter(DocumentFamily.TEXT, "HTML (StarWriter)");
//for .doc documents.
DocumentFormat doc = new DocumentFormat("Microsoft Word", DocumentFamily.TEXT, "application/msword", "doc");
doc.setExportFilter(DocumentFamily.TEXT, "MS Word 97");