HomePage » Linux » LinuxPrinting


Adding a pdf printer to cups


rpm
http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/download.shtml

manual
Test platform: CentOS 5.0 x86
Create the directory
mkdir /usr/lib/cups/pdf


Create /usr/lib/cups/pdf/ps2pdf.cups and set its permission to 755
ps2pdf.cups
#!/bin/sh
# Convert PostScript to PDF.
umask 002
OPTIONS=""
while true
do
        case "$1" in
        -*) OPTIONS="$OPTIONS $1" ;;
        *)  break ;;
        esac
        shift
done

if [ $# -lt 1 -o $# -gt 2 ]; then
        echo "Usage: `basename $0` [options...] input.ps [output.pdf]" 1>&2
        exit 1
fi

infile=$1;

if [ $# -eq 1 ]
then
        outfile=$1
else
        outfile=$2
fi

# Doing an initial 'save' helps keep fonts from being flushed between pages.
exec gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
        -sOutputFile=$outfile $OPTIONS -c save pop -f $infile
exec chmod a+r $outfile


Create the backend file /usr/lib/cups/backend/pdf, chmod it to 755. The backend file contains specifications for port / uri / etc.
pdf
#!/bin/sh
#
umask 002
PDFBIN=/usr/lib/cups/pdf/ps2pdf.cups
FILENAME=
# filename of the PDF File
PRINTTIME=`date +%Y-%m-%d_%H.%M.%S`
# no argument, prints available URIs
if [ $# -eq 0 ]; then
        if [ ! -x "$PDFBIN" ]; then
                exit 0
        fi
        echo "direct pdf \"Unknown\" \"PDF Creator\""
        exit 0
fi
# case of wrong number of arguments
if [ $# -ne 5 -a $# -ne 6 ]; then
        echo "Usage: pdf job-id user title copies options [file]"
        exit 1
fi
# get PDF directory from device URI, and check write status
PDFDIR=${DEVICE_URI#pdf:}
if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
        echo "ERROR: directory $PDFDIR not writable"
        exit 1
fi
# generate output filename
OUTPUTFILENAME=
if [ "$3" = "" ]; then
        OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
        if [ "$2" != "" ]; then
                OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
        else
                OUTPUTFILENAME="$PDFDIR/$PRINTTIME.pdf"
        fi
        echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
fi
# run ghostscript
if [ $# -eq 6 ]; then
        $PDFBIN $6 $OUTPUTFILENAME >& /dev/null
else
        $PDFBIN - $OUTPUTFILENAME >& /dev/null
fi

exit 0


Download and install ppd file from Adobe. Go to http://www.adobe.com/support/downloads/product.jsp?product=44&platform=Windows, search under postscript printer driver > Adobe PPD files.
cp ADIST5.PPD /usr/share/cups/model/distiller.ppd
lpadmin -p PDF -v pdf:/opt/pdf/ -E -P /usr/share/cups/model/distiller.ppd
service cups restart


You have just created a PDF printer on cups! PDF files will be output to the URI you specified with the lpadmin command. In the above example, they will be written to /opt/pdf with a filename like this - root-2007-04-21_08.53.53.pdf

Comments [Hide comments/form]
3mvEzD <a href="http://weiqyknsnjkh.com/&
-- ppp-46-33-232-64.wil (2011-12-23 13:21:35)
UJfzre <a href="http://dboljesgipsu.com/&
-- ppp-109-104-166-79.w (2012-01-05 20:38:49)
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki