How to convert HTML ==> RTF in Java?

Duprat picture Duprat · Sep 20, 2010 · Viewed 11.6k times · Source

The basic API of JAVA that uses RTFEditorKit and HTMLEditorKit, is not able of recognize tags like <br/> and <table>. So I have searched on internet a better way of converting HTML to RTF and i have found two solutions that seem to work. JODConverter and HTML-to-RTFconverter. The first one needs OppenOffice installed to work and the second one uses DLL, so it can’t be used on Linux.

Does anyone know about other solution?

Thanks for any help!!!!

Answer

Christian Kuetbach picture Christian Kuetbach · Sep 23, 2010

If it is valid html, you can use Apache-FOP.

There are stylesheets for transforming html to FO.

Apache FOP can write PDF and RTF as well.

http://www.torsten-horn.de/techdocs/java-xsl.htm#XSL-FO-Java

http://html2fo.sourceforge.net/index.html