[cups] rtf to pdf conversion using cupsfilter

Kurt Pfeifle kurt.pfeifle at googlemail.com
Wed Sep 28 11:12:31 PDT 2016


> ------------------------------
>
> Message: 3
> Date: Tue, 27 Sep 2016 16:49:41 +0000
> From: "Paquin, Brian" <brian.paquin at yale.edu>
> To: "cups at cups.org" <cups at cups.org>
> Subject: [cups] rtf to pdf conversion using cupsfilter
> Message-ID: <F0E0BBED-563C-4087-B2A9-18F10CFCAA48 at yale.edu>
> Content-Type: text/plain; charset="us-ascii"
>
> In Mac OS X 10.9, we were able to convert RTF documents into PDF using:
>
> cupsfilter my_document.rtf > my_document.pdf
>
> This spits back some basic debug info, but works (see below).
>
> But cupsfilter on OS 10.11 is missing that functionality, and returns:
>
> cupsfilter: No filter to convert from text/rtf to application/pdf.
>
> Any ideas how we can get this functionality back?
> (we hoped it would come back in 10.12, but we get the same behavior as
> 10.11)
>
> If not something simple (to add/configure), what other solutions would you
> recommend to convert RTFs into PDFs (the documents have complex formatting
> but cupsfilter worked well)?
>
> Thank you,
>
> Brian
>
> $ cupsfilter ~/Desktop/my_document.rtf > my_document.pdf
> DEBUG: argv[0]="cupsfilter"
> DEBUG: argv[1]="1"
> DEBUG: argv[2]="administrator"
> DEBUG: argv[3]="my_document.rtf"
> DEBUG: argv[4]="1"
> DEBUG: argv[5]=""
> DEBUG: argv[6]="/Users/administrator/Desktop/my_document.rtf"
> DEBUG: envp[0]="<CFProcessPath>"
> DEBUG: envp[1]="CONTENT_TYPE=text/rtf"
> DEBUG: envp[2]="CUPS_DATADIR=/usr/share/cups"
> DEBUG: envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts"
> DEBUG: envp[4]="CUPS_SERVERBIN=/usr/libexec/cups"
> DEBUG: envp[5]="CUPS_SERVERROOT=/private/etc/cups"
> DEBUG: envp[6]="LANG=en_US.UTF8"
> DEBUG: envp[7]="PATH=/usr/libexec/cups/filter:/usr/bin:/usr/
> sbin:/bin:/usr/bin"
> DEBUG: envp[8]="PPD=/System/Library/Frameworks/
> ApplicationServices.framework/Versions/A/Frameworks/
> PrintCore.framework/Versions/A/Resources/Generic.ppd"
> DEBUG: envp[9]="PRINTER_INFO=cupsfilter"
> DEBUG: envp[10]="PRINTER_LOCATION=Unknown"
> DEBUG: envp[11]="PRINTER=cupsfilter"
> DEBUG: envp[12]="RIP_MAX_CACHE=128m"
> DEBUG: envp[13]="USER=administrator"
> DEBUG: envp[14]="CHARSET=utf-8"
> DEBUG: envp[15]="FINAL_CONTENT_TYPE=application/pdf"
> INFO: nstexttopdf (PID 19583) started.
> DEBUG: nstexttopdf - opened PPD file "/System/Library/Frameworks/
> ApplicationServices.framework/Versions/A/Frameworks/
> PrintCore.framework/Versions/A/Resources/Generic.ppd"...
> INFO: nstexttopdf (PID 19583) exited with no errors.
> $
>
>
> [Yale Pathology Logo]
> Brian Paquin
> Help Desk Support Yale Pathology ITS
>
> ************************************
>


There are several options to convert RTF to PDF on the command line.

One is to use LibreOffice in "headless" mode. (This method has as an
advantage that it works on multiple platforms, not just OS X.) The
basic command to achieve this is:

    mkdir ${HOME}/rtf2pdfs ;

    soffice                                                   \
       --headless                                             \
       "-env:UserInstallation=file:///tmp/LO_RTFconv_${USER}" \
       --convert-to pdf:writer_pdf_Export                     \
       --outdir ${HOME}/rtf2pdfs                              \
       source-file.rtf

To understand the details about this command I recommend to look at
this StackOverflow answer:

    http://stackoverflow.com/a/30465397/359307

Another one is the commandline tool "unrtf", also available for multiple
platforms:

    http://www.gnu.org/software/unrtf/unrtf.html

On OS X it is available via MacPorts (and most likely, also via HomeBrew).
AFAIR, it can convert to PostScript (from where it would be easy to go to
PDF).

Once you have a working command line for your type of RTF files, it should
be easy to script it into an "rtf2pdf" script which works as a CUPS filter.



More information about the cups mailing list