Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: Command Line Utility Convert RTF to PDF?

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.

like image 990
StackOverflowNewbie Avatar asked Jul 28 '11 22:07

StackOverflowNewbie


People also ask

How do I convert an RTF file to PDF?

On a Windows 10 machine, open the file you want to convert. Press the Control and P keys to open the system's print dialogue box. In the box, under Printer, select Microsoft Print to PDF and click the Print button to save a copy of the R.T.F. file as a PDF to your computer.

How do I convert a text file to PDF in Unix?

Once all prerequisites are installed, follow these two steps to generate a PDF file from a text file. First, convert a text file to Postscript format by using enscript command-line tool. Finally convert the generated postscript file to a PDF file.

How do I convert to PDF in Ubuntu?

Alternatively, click the File menu and select Export as, and then Export as PDF. The second method gives you a lot of options for your PDF file creation. Click the Export button, and name the file if you haven't already done so. Now your file will be exported as a PDF file.


2 Answers

Alternatively, you can use libreoffice for this task:

libreoffice --headless --invisible --norestore --convert-to pdf source-file.rtf
like image 114
Anonymous Coward Avatar answered Dec 04 '22 06:12

Anonymous Coward


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...).

like image 39
Digger Avatar answered Dec 04 '22 08:12

Digger