I got this script working on the weekend.

I added a printer in kups, to print using a PS ppd file, I chose to use the adobe 
distiller ppd, though this also worked with a Fuji Xerox DC250 PS ppd.


Under various circumstances using the original script it appeared that no file would 
be generated.
This is my final script modification, with some things taken from the pdfprint script, 
( http://e-smith.saxdalen.com/howto/How_to_install_PDF_over_LAN.html)

/usr/lib/cups/backend/pdf

#!/bin/sh
#
# This script is intended to be used as a CUPS backend, to create
# PDF file on-the-fly. Just create a printer using the device uri
# pdf:/path/to/dir/. When printing to this printer, a PDF file
# will be generated in the directory specified. The file name will
# be either "<jobname>.pdf" or "unknown.pdf", depending wether the
# jobname is empty or not.
#
# To use it, simply copy this script to your backend directory, and
# create a printer with the correct URI. That's it.
#
# Copyright (C) Michael Goffioul ([EMAIL PROTECTED]) 2001
LOGFILE=/tmp/pdf.log
PDF13=`which ps2pdf13`
FILENAME= 
# this is borrowed from printpdf script for the filename
PRINTTIME=`date +%b%d-%H%M%S`

echo "Executable: $PDF13" > $LOGFILE
echo "Arguments: |$1|$2|$3|$4|$5|$6|" >> $LOGFILE 
echo $# $PRINTTIME >> $LOGFILE

# case of no argument, prints available URIs
if [ $# -eq 0 ]; then
if [ ! -x "$PDF13" ]; then
exit 0
fi
echo "direct pdf \"Unknown\" \"PDF Writing\""
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 

echo "PDF directory: $PDFDIR" >> $LOGFILE 

# generate output filename
OUTPUTFILENAME=
if [ "$3" = "" ]; then
OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
# OUTPUTFILENAME="$PDFDIR/${3//[^[:alnum:]]/_}.pdf"
# I changed this to user name, and the printtime to track down who
# printed the PDF and when, samba printing just uses nobody

OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
fi 

echo "Output file name: $OUTPUTFILENAME" >> $LOGFILE 

# run ghostscript
if [ $# -eq 6 ]; then
ps2pdf13 $6 $OUTPUTFILENAME 
#>& /dev/null
else
ps2pdf13 - $OUTPUTFILENAME >& /dev/null
fi

# modify ownership and permissions on the file
#  - world readable
#  - owns to user specified in argument
chmod a+r $OUTPUTFILENAME
if [ "$2" != "" ]; then
chown $2 $OUTPUTFILENAME
fi 

exit 0

--------------------------------
The directory where the pdf file is created has these properties
drwxrwxrwx    2 nobody   lp           4096 Mar 11 09:33 /mnt/pdfdrop/

It prints now from Samba and locally and generates a PDF file in /mnt/pdfdrop

Chris

It would be good though to add these enhancements, mail user to advise that his pdf 
file has been printed, mail user his pdf file if not too big.



On Sat, 9 Mar 2002 00:25:21 +1100 
"Michael Goffioul" <[EMAIL PROTECTED]> wrote:

> Christopher Booth wrote:
> > 
> > Ok
> > 
> > I went through the script, which I copied and pasted into a text file.
> > There was some bad line wrap :|
> > 
> > Now printing is fine, except that the pdf file isn't there
> > 
> > %more /tmp/pdf.log
> > Executable:
> > Arguments: |37|root|Testpage|1|||
> > PDF directory: /mnt/pdfdrop
> > Output file name: /mnt/pdfdrop/Testpage.pdf
> > 
> > on doing an ls /mnt/pdfdrop
> > the directory is empty
> > 
> > any ideas ?
> 
> Yes, the script can't find the ps2pdf binary. This file is actually a
> script provided by recent ghostscript versions. You need to make this
> script available to the pdf script. Equivalently, you may edit the
> pdf script and enter directly the path of ps2pdf in the GSBIN variable
> (instead of the current `which ps2pdf`).
> 
> Bye.
> Michael.
> 
> -- 
> ------------------------------------------------------------------
> Michael Goffioul              IMEC-DESICS-MIRA
> e-mail: [EMAIL PROTECTED]      (Mixed-Signal and RF Applications)
> Tel:    +32/16/28-8510                Kapeldreef, 75
> Fax:    +32/16/28-1515                3001 HEVERLEE, BELGIUM
> ------------------------------------------------------------------
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.330 / Virus Database: 184 - Release Date: 28/02/02
>  
-- 
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to