Linux: Command Line Utility Convert RTF to PDF?
Asked Answered
E

5

19

Any recommendations to convert an RTF to a PDF? I need to do this from my LAMP application, so a command line utility like GhostScript would be ideal.

Engadine answered 28/7, 2011 at 22:8 Comment(2)
This may be usefulBrigittebriley
use UnRTF, convert to .ps and then ps2pdf to get the pdf. UnRTF also available on Win32Phyllotaxis
V
5
sudo apt-get install ted

/usr/share/ted/Ted/rtf2pdf.sh source-file dest-file

or visit this link

Veradi answered 28/7, 2011 at 22:11 Comment(3)
What is ted, is there a website or so? It doesn't seem to be part of Ubuntu. Also, did you just search and paste ;-)Notice
@Kerrek - knew about ted, so I googled it and copypasted the first example I could find which was the link provided by you.Veradi
#sudo apt-get install ted Reading package lists... Done Building dependency tree Reading state information... Done E: Couldn't find package tedNosology
W
26

Alternatively, you can use libreoffice for this task:

libreoffice --headless --invisible --norestore --convert-to pdf source-file.rtf
Willhite answered 14/11, 2014 at 10:48 Comment(1)
Persumably there is a version of java already provided with my libreoffice installation, but it sin't found by default:javaldx: Could not find a Java Runtime Environment! Warning: failed to read path from javaldxPolite
V
5
sudo apt-get install ted

/usr/share/ted/Ted/rtf2pdf.sh source-file dest-file

or visit this link

Veradi answered 28/7, 2011 at 22:11 Comment(3)
What is ted, is there a website or so? It doesn't seem to be part of Ubuntu. Also, did you just search and paste ;-)Notice
@Kerrek - knew about ted, so I googled it and copypasted the first example I could find which was the link provided by you.Veradi
#sudo apt-get install ted Reading package lists... Done Building dependency tree Reading state information... Done E: Couldn't find package tedNosology
N
3

In my Ubuntu 10.4 I have unrtf, which "converts RTF to HTML, LaTeX, Postscript". From Postscript it should be a trivial application of ps2pdf to get PDFs.

Notice answered 28/7, 2011 at 22:13 Comment(1)
My rtf was not well formed, so this utility failed to convert. As long as there is no Ted in ubuntu sources now, I converted my rtf with libreoffice heedlessGong
H
1

unoconv does this very conveniently. (FYI, I'm currently using version 0.5-1 of same). I have to first run a unoconv --listener & command, followed by a unoconv *.rtf command, for example...

UPDATE: I can verify that, on my Debian Jessie machine, version 0.6 of unoconv behaves in the above fashion. However, the unoconv --listener & command is now no longer necessary (indeed, same seems to cause difficulties if later attempting to open a LibreOffice file...).

Haiduk answered 19/10, 2019 at 17:28 Comment(0)
B
0

Under Cent OS 6, these steps worked for me to convert RTF to PDF from a php file:

  1. yum install Ted
  2. yum install ghostscript
  3. Download rtf2pdf.sh to some path like: /var/www/html/lib, where Apache has sufficient permissions
  4. shell_exec('sh /lib/rtf2pdf.sh /files/test.rtf /files/test.pdf');
Brigittebriley answered 28/3, 2014 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.