8

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

Jeff
  • 21,744
  • 6
  • 51
  • 55
Leandro
  • 101
  • 1
  • 3
  • 7

5 Answers5

3

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

Christian Kuetbach
  • 15,850
  • 5
  • 43
  • 79
3

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.

jqa
  • 1,340
  • 6
  • 17
  • I have tried this option today. It worked as you said. I didn't know that Microsoft Word and OpenOffice were able of converting HTML --> RTF. Thank you so much my friend! – Leandro Oct 06 '10 at 21:35
  • Great tip! Even better if you use content type "application/vnd.openxmlformats-officedocument.wordprocessingml.document" and .docx – Federico Pugnali Feb 26 '14 at 17:28
0

By RTF conversion there is an important issue to care about: a target RTF viewer. All of them declare RTF support, but, for instance, Notepad.exe can only show images in WMF format, it does not display headers and footers. TextEdit on MacOS can only deal with images embedded as a kind of active objects and has troubles with tables, OpenOffice is not tolerant to minor markup inconsistencies etc.

My favorite tool for HTML->RTF conversion is PD4ML - it produces clean, almost human-readable RTF markup and successfully solves another challenging problem for RTF generating tool - a support of nested tables (if you work with HTML - they are everywhere).

zfr
  • 339
  • 4
  • 11
0

You can take a look at RTF Template (http://rtftemplate.sourceforge.net/) Don't know if it fits your needs, but I used several times under Linux and was OK.

Grieih
  • 61
  • 1
  • 5
  • I have a HTML editor (richfaces) that generates a HTML output and I need to convert it to RTF. I think RTF Template won’t help. Thanks for helping! – Leandro Sep 20 '10 at 20:50
0

I already used the html-to-pdf and got the expected result. I have helped.