Home Blog CV Projects Patterns Notes Book Colophon Search

Converting Word RTF to PDF on Debian

24 Sep, 2007

This is actually very easy. First install Ted, an old UNIX text editor with this command:

$ sudo apt-get install ted

You'll also need Ghostscript but this is probably already installed, if not run:

$ sudo apt-get install gs-afpl

Then download the rtf2pdf.sh script from ftp://ftp.nluug.nl/pub/editors/ted/rtf2pdf.sh and run this command:

$ sh rtf2pdf.sh file.rtf output.pdf

and that's it, very easy and it actually works. I've attached a text version of the rtf2pdf.sh script here as well.

Here's a very short program which uses this from Python:

import os

def convert(rtf, pdf):
    pipe = os.popen("sh rtf2pdf.sh %s %s"%(rtf, pdf), "r")
    error = pipe.read()
    if error:
        print "ERROR. An error occurred here is the description..."
        print
        print error

if __name__ == '__main__':
    convert('test.rtf', 'test.pdf')

Copyright James Gardner 1996-2020 All Rights Reserved. Admin.