简体   繁体   中英

Java generate PDF from RTF

I want to generate PDF file from RTF file. I have tried following.

  1. Itext It's already outdated and new version doesn't support rtf.

  2. JDocConverter It uses OpenOffice on the background. it is working fine, there is only one problem. Open office doesn't support drawing object in RTF.

Any other possible and reliable solutions?

Note: It would be fine don't use any commercial software.

Windows has native convert RTF to PDF using command line, however it will to a degree be limited, so it will use direct convert text and images, but it will depend on rtf syntax as to which drawn objects are supported. WORD ART drawing objects need MS Word to print

在此处输入图像描述

The output looks reasonable but here is the source in MSWord where the art was clearly not handled by the non-word printout.

在此处输入图像描述

Under Windows you could print to CutePDF Writer . This freeware uses Ghostscript as a back end.

You may try Aspose.Words for Java to convert RTF file to PDF format. You can load a file in RTF format into Aspose.Words for Java and then save it to PDF format . Please note that while loading specify RTF as LoadFormat value and pass PDF as SaveFormat value while saving the document. This doesn't require OpenOffice or any other software to be installed for the conversion to work.

Disclosure: I work as developer evangelist at Aspose.

Best way to do it is use MS Office. And Ms Office is able to save file in PDF format (you need install some addons I think).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM