Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a free way to convert RTF to PDF?

Tags:

How can I programmatically convert RTF documents to PDF?

like image 442
user63898 Avatar asked Feb 25 '09 15:02

user63898


People also ask

Is there an actually free PDF converter?

PDFelement is the best free PDF converter for Windows 10, 8, 7, and Mac. can meet all your PDF needs. You can convert PDF to or from almost any popular file format, including Word, Excel, PowerPoint, images, text, HTML, and more. In addition to converting and creating PDFs, you can also edit text, images, and pages.

Is Rich Text Format the same as PDF?

A Rich Text Document (. rtf file) is a versatile format that allows advanced formatting to be viewed on multiple platforms. Please note that RTFs, unlike PDFs, are easily edited.


2 Answers

OpenOffice.org can be run in server mode (i.e. without any GUI), can read RTF files and can output PDF files.

like image 123
Joachim Sauer Avatar answered Oct 01 '22 02:10

Joachim Sauer


You have a number of options depending on:

  • the platform(s) your application will be running on
  • whether your application will be a server application (e.g. a web service that you set up once and then it runs), or a widely-available desktop application (e.g. something that must be easily downloadable and installable by many people)
  • whether you are willing to put little or more programming effort into getting the solution to work
  • whether you are flexible as to the programming language you will use

Here are some options:

  1. PDFCreator + COM
    • Windows only
    • suitable for both desktop and server applications
    • medium programming effort
    • any language that allows you to speak COM
  2. OpenOffice ( + JODConverter - optional )
    • Cross-platform (Windows, Linux, etc.)
    • suitable for server applications, as OpenOffice is a 100MB+ download
    • low programming effort
    • Java (if using JODConverter), or any language that can interface with OpenOffice's UNO
  3. IText + Apache POI
    • Cross-platform (Windows, Linux, etc.)
    • suitable for both desktop and server applications
    • high programming effort
    • Java

EDIT

Here is an older post that has some commonality with your question.


EDIT 2

I see from your comments that you are on Linux and open to either C++ or Java. Definitely use option 2.

  • JODConverter (Java): the library takes care of spawning OpenOffice in headless mode and talking Uno to it on your behalf. You provide JODConverter with an input and output file name as well as the input and output types (e.g. rtf and pdf), and when it returns to you the output file is ready.
  • C++: you can fork+exec one (or more, for load balancing) OpenOffice instances in headless mode (soffice will listen for UNO requests on a socket e.g. port 8100.) From your application use Uno/CPP to instruct OpenOffice to perform the conversion the same way JODConverter does (see the JODConverter source code for how to do this.)

/opt/openoffice.org3/program/soffice.bin \
-accept=socket,host=127.0.0.1,port=8100;urp; \
-headless -nocrashreport -nodefault \
-nolockcheck -nologo -norestore

I am successfully using JODConverter from a Java app to convert miscellaneous document types (some documents dynamically generated from templates) to pdf.

like image 35
vladr Avatar answered Oct 01 '22 02:10

vladr