Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert HTML ==> RTF in Java?

Tags:

java

html

rtf

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!!!!

like image 793
Leandro Avatar asked Sep 20 '10 20:09

Leandro


2 Answers

Do they want it in RTF or do they want it in Word format? There's a big difference.

Ensure your editor is generating XHTML (or convert it yourself with jtidy, htmlcleanup etc) then download the content as an XHTML but with a .doc extension and the MS Word mime type. Word 2003 or higher will open it as a word doc.

like image 123
jqa Avatar answered Nov 03 '22 12:11

jqa


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

like image 20
Christian Kuetbach Avatar answered Nov 03 '22 11:11

Christian Kuetbach