mwestern@sola.com.au
2003-May-15 06:37 UTC
[Samba] PDF Samba Printer - ps2pdf Only Letter Size?
I've got a nice working pdf samba printer emailing the right person thanks to PeteFwee and David F and am doing a little testing. I've just realized that it's set to Letter when it creates the .pdf file. and i've googled till i'm blue in the face and can't see any options that says page size or something similar. i'm running ghostscript 7.04. does anybody know how to make ps2pdf do A4 size paper? Here's my slightly modified script so it mails the user back... Regards Matthew _________________________________ #!/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 (goffioul@imec.be) 2001 LOGFILE=/var/log/cups/pdf.log PDFBIN=`which ps2pdf` FILENAME= # this is borrowed from printpdf script for the filename PRINTTIME=`date +%b%d-%H%M%S` echo "Executable: $PDFBIN" >> $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 "$PDFBIN" ]; 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 OUTPUTFILENAMEif [ "$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 # $PDFBIN -dPpdfSettings=/default $6 "$OUTPUTFILENAME" $PDFBIN $6 "$OUTPUTFILENAME" #>& /dev/null else $PDFBIN - "$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 #Sendmail to the owner. DATE=`date +%d%b%Y-%H:%M:%S` MAILFILE=/tmp/mailtemp HEADER=/tmp/header TO=$2'@sola.com.au' SUBJECT='PDF Printer Job' BODY='PDF Created: '$DATE echo From: PDFPrinter@sola.com.au >> $HEADER echo To: $TO >> $HEADER #echo Cc: $CC >> $HEADER #echo Bcc: $BCC >> $HEADER echo Subject: $SUBJECT >> $HEADER echo "" >> $HEADER echo "" >> $HEADER echo $BODY >> $HEADER echo "" >> $HEADER cat $HEADER > $MAILFILE uuencode $OUTPUTFILENAME $2-$PRINTTIME.pdf >> $MAILFILE cat $MAILFILE | /usr/lib/sendmail -t rm $MAILFILE rm $HEADER exit 0
Matthew Western
2003-May-15 06:39 UTC
[Samba] PDF Samba Printer - ps2pdf Only Letter Size?
Hi all, I've got a nice working pdf samba printer emailing the right person thanks to PeteFwee and David F and am doing a little testing. I've just realized that it's set to Letter when it creates the .pdf file. and i've googled till i'm blue in the face and can't see any options that says page size or something similar. i'm running ghostscript 7.04. does anybody know how to make ps2pdf do A4 size paper? Here's my slightly modified script so it mails the user back... Regards Matthew _________________________________ #!/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 (goffioul@imec.be) 2001 LOGFILE=/var/log/cups/pdf.log PDFBIN=`which ps2pdf` FILENAME= # this is borrowed from printpdf script for the filename PRINTTIME=`date +%b%d-%H%M%S` echo "Executable: $PDFBIN" >> $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 "$PDFBIN" ]; 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
Matthew Western mwestern at affairs.net.au wrote on Samba-Digest:> Thu May 15 16:09:39 GMT 2003 > > > Hi all, > > I've got a nice working pdf samba printer emailing the right person> thanks to PeteFwee and David F and am doing a little testing. I've > just realized that it's set to Letter when it creates the .pdf file. > and i've googled till i'm blue in the face and can't see any options > that says page size or something similar. i'm running ghostscript 7.04.> does anybody know how to make ps2pdf do A4 size paper?From the script below I conclude you are using it based on CUPS (though you don't mention it.) CUPS uses "PPDs" to configure printers and to offer user-selectable printjob options that may be applied to the printer. This PPD may or may not include an option to change paper sizes (depending on the printer). A "PDF" printer can certainly support various paper sizes. There is no "ideal" PPD for a PDF printer out there. I may go on a write one as soon as I find the time. For the time being, you may want to resort to the distiller.ppd (which users of Acrobat Distiller on Windows may have in their [print$] share. This gives you options to select paper size as well as resolutions of vector-based graphics in the output. Which PPD is used for your current PDF printer? You may want to read the short HOWTO posted by "Tom" in March on this list, or the whole thread about it with lots of background info: http://lists.samba.org/pipermail/samba/2003-March/093504.html http://lists.samba.org/pipermail/samba/2003-April/093503.html The general (CUPS) printing background explanations are here: http://www.linuxprinting.org/kpfeifle/SambaPrintHOWTO/ Cheers, Kurt> Here's my slightly modified script so it mails the user back...BTW, there is no modification obvious in what you posted....> Regards > > Matthew >Cheers, Kurt
Wolfram Quester
2003-May-15 15:52 UTC
[Samba] PDF Samba Printer - ps2pdf Only Letter Size?
Hi Matthew, On Thu, May 15, 2003 at 04:09:39PM +0930, Matthew Western wrote:> Hi all, > > I've got a nice working pdf samba printer emailing the right person thanks to PeteFwee and David F and am doing a little testing. I've just realized that it's set to Letter when it creates the .pdf file. and i've googled till i'm blue in the face and can't see any options that says page size or something similar. i'm running ghostscript 7.04.I agree it's quite hard to find. if you do man ps2pdf you can read> SEE ALSO > gs(1), ps2pdfwr(1), > Ps2pdf.htm in the Ghostscript documentationIn Ps2pdf.htm you find that it understands all options from gs(1), so you have to do man gs(1), where you can read> To select a specific paper size, use the command line switch > -sPAPERSIZE=a_known_paper_size > for instance > -sPAPERSIZE=a4 > or > -sPAPERSIZE=legal<...snip...>> > # Copyright (C) Michael Goffioul (goffioul@imec.be) 2001 > > LOGFILE=/var/log/cups/pdf.log > > PDFBIN=`which ps2pdf`Please correct me, if I'm wrong, but I thought one of the purposes of variables like these is to prevent scripts from executing binaries provided by the user. These binaries can do things not intended by the original author of the script. Your method to initialize the PDFBIN variable does not ensure this prevention. To make sure the script uses the correct ps2pdf you should use the absolute path. I'm not seeing where you call ps2pdf in your script and mail it back to the user. Is it just for testing purposes or a script running before another one? Best regards, Wolfi> > FILENAME= > > # this is borrowed from printpdf script for the filename > > PRINTTIME=`date +%b%d-%H%M%S` > > echo "Executable: $PDFBIN" >> $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 "$PDFBIN" ]; 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 > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba--
Matthew Western
2003-May-15 23:05 UTC
[Samba] PDF Samba Printer - ps2pdf Only Letter Size?
Mate you are a legend. it was the end of the day and my eyes had dropped out due to too much reading. I appreciate it very much indeed..... now to impress the users with free .pdfs :) thanks & regards Matthew -----Original Message----- From: Wolfram Quester [mailto:wquester@mittelerde.physik.uni-konstanz.de] Sent: Friday, May 16, 2003 1:22 AM To: samba@lists.samba.org Cc: Matthew Western Subject: Re: [Samba] PDF Samba Printer - ps2pdf Only Letter Size? Hi Matthew, On Thu, May 15, 2003 at 04:09:39PM +0930, Matthew Western wrote:> Hi all, > > I've got a nice working pdf samba printer emailing the right person thanksto PeteFwee and David F and am doing a little testing. I've just realized that it's set to Letter when it creates the .pdf file. and i've googled till i'm blue in the face and can't see any options that says page size or something similar. i'm running ghostscript 7.04. I agree it's quite hard to find. if you do man ps2pdf you can read> SEE ALSO > gs(1), ps2pdfwr(1), > Ps2pdf.htm in the Ghostscript documentationIn Ps2pdf.htm you find that it understands all options from gs(1), so you have to do man gs(1), where you can read> To select a specific paper size, use the command line switch > -sPAPERSIZE=a_known_paper_size > for instance > -sPAPERSIZE=a4 > or > -sPAPERSIZE=legal<...snip...>> > # Copyright (C) Michael Goffioul (goffioul@imec.be) 2001 > > LOGFILE=/var/log/cups/pdf.log > > PDFBIN=`which ps2pdf`Please correct me, if I'm wrong, but I thought one of the purposes of variables like these is to prevent scripts from executing binaries provided by the user. These binaries can do things not intended by the original author of the script. Your method to initialize the PDFBIN variable does not ensure this prevention. To make sure the script uses the correct ps2pdf you should use the absolute path. I'm not seeing where you call ps2pdf in your script and mail it back to the user. Is it just for testing purposes or a script running before another one? Best regards, Wolfi> > FILENAME> > # this is borrowed from printpdf script for the filename > > PRINTTIME=`date +%b%d-%H%M%S` > > echo "Executable: $PDFBIN" >> $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 "$PDFBIN" ]; 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 > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba--