PCL to PDF document

Mike McArthur michelmcarthur at gmail.com
Fri Jun 22 08:36:13 PDT 2012


Hello;

I am trying to get a virtual printer setup in cups that "saves" a document to PDF format.  I installed ghostscript and downloaded a custom filter and backend that would convert the plain text document to PDF.

So far everything is working fine, save for a few issues.

1) I need to modify the document so it saves the pdf in a landscape format, or change the text size.  Any attempts to modify the filter seem to not cause any changes

2) Alternatively I will need to install a PCL to PDF filter.



I have also attempted to use ghostscript directly to print off the plaintext file into landscape mode by executing the following:

gs -q -dNOPAUSE -dBATCH -dORIENT1=true -sDEVICE=pdfwrite -sOutputFile=/tmp/MIKE2.pdf -c save pop -f /tmp/KINS.pdf

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/tmp/MIKE3.pdf -c save pop -c "<< /PageSize [612 792] /Orientation 3 >> setpagedevice" 90 rotate 0 -612 translate -f /tmp/KINS.pdf



backend/pdf


umask 002
PDFBIN=/usr/lib/cups/pdf/ps2pdf.cups
FILENAME=
PDFDIR=${DEVICE_URI#pdf:}
PDFDIR=/tmp/
if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
        echo "ERROR: directory $PDFDIR not writable"
        exit 1
fi

OUTPUTFILENAME=
if [ "$3" = "" ]; then
        OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
        if [ "$2" != "" ]; then
                OUTPUTFILENAME="$PDFDIR/MIKE-$PRINTTIME.pdf"
        else
                OUTPUTFILENAME="$PDFDIR/MIKE-$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



ps2pdf.cups

#!/bin/sh
# Convert PostScript to PDF.
umask 002
OPTIONS=""
sleep 30
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
echo "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
        -sOutputFile=$outfile $OPTIONS -c save pop -f $infile" >> /tmp/mike.txt
# 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





More information about the cups mailing list