0
votes

I'm new to Docx4j and I need some advice.

Currently I'm creating a simple (X)HTML document with Java. It contains some information from a database. After creating this html, Docx4j creates a Word-Docx file by using a very simple word template. This works fine.

Now I have to enhance this HTML. One database value contains a byte array which holds an RTF file.

Currently I'm putting this data into HTML as a string.

String content = new String(allbytes,"UTF-8");
html+=content;

At least the html files looks like this:

<html>
....
<td>
    {\rtf1\ansi\deflang1033\ftnbj\uc1\deff1..... 
</td>
...
</html>

Docx4J now creates a Word-Docx which shows this RTF as a string and not as an imported RTF file.

Off course not, but I wish to see it as imported RTF. How can I archive this? Is there a simple way to do this?

1

1 Answers

0
votes

Converting rtf to docx content is outside the scope of docx4j.

You'll need to look for a third party solution which does rtf to docx, or failing that, rtf to (x)html (see Convert Rtf to HTML)

You could try http://sourceforge.net/projects/rtf2xml/ and then transform the XML to WordML.

Another possibility may be LibreOffice via JODConverter.