How can I programmatically convert RTF documents to PDF?
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.
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.
OpenOffice.org can be run in server mode (i.e. without any GUI), can read RTF files and can output PDF files.
You have a number of options depending on:
Here are some options:
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.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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With