[cups.bugs] Failure to Print Multiple Copiee with Raw Option

Michael R Sweet msweet at apple.com
Mon Sep 15 10:20:30 PDT 2008


Don Badrak wrote:
>> Don Badrak wrote:
>>> ...
>>> Do I need to drop the number of copies somehow before they get passed off to the next filter or backend?  I'd like for a fix by HP firmware to all of a sudden not end up getting n^2 copies if I put in the PJL code.
>> No, as soon as you provide your filter, it is responsible for copy
>> generation.
> 
> I've created this script.
> 
> ### start-of-script
> #!/bin/bash
> 
> # this handles the case where the backend device can accept raw PDF but
> # doesn't properly print out multiple copies when using raw mode.  This
> # appears to be limited to the HP DesignJet 4500ps plotter series. Place
> # this line in the PPD file for each printer:
> #
> #     *cupsFilter: "application/pdf 0 pdfraw"
> #
> # this will send out the PJL to print out the right number of copies.
> #
> # filter job user title num-copies options [ filename ]
> 
> jobnumber=$1
> user=$2
> title=$3
> copies=$4
> options=$5
> filename=$6
> hostname=`hostname -s`
> 
> if [ $copies -gt 999 -o $copies -lt 1 ]
> then
>    echo "INFO: copies out of range (1 .. 999), using default of 1"
>    copies=1
> fi
> 
> # See if we have a filename on the command-line...
> if test -z "$filename"; then
>         ifile="-"
> else
>         ifile="$filename"
> fi
> 
> echo "DEBUG: Sending PJL to set COPIES=$copies" 1>&2
> 
> printf "\e%%-12345X at PJL JOB NAME=\"${jobnumber} ${title}\"\r\n"
> printf "@PJL SET COPIES = $copies\r\n"
> printf "@PJL SET USERNAME = \"${user}@${hostname}\"\r\n"
> printf "@PJL ENTER LANGUAGE = PDF\r\n"
> echo "DEBUG: Sending PDF file $ifile" 1>&2
> cat $ifile
> printf "\e%%-12345X at PJL EOJ\r\n"
> 
> exit
> ### end-of-script
> 
> It works great! Thanks.  Now, on the web interface, it even shows me the  username and the job name.
> 
> There is one slight problem -- it no longer logs to the /var/log/cups/page_log when it completes.  Is there something I'm missing in the script? Thanks.

OK, you'll need to add an echo with a PAGE: message with the number
of pages in the PDF file.  The pdfinfo command will give you a page
count, and then you can multiply by the number of copies and write
a message like this:

     pages=`pdfinfo $ifile | grep '^Pages:' | awk '{print $2}'`
     total=`expr $pages \* $copies`
     echo "PAGE: total $total" 1>&2

-- 
______________________________________________________________________
Michael R Sweet                        Senior Printing System Engineer





More information about the cups mailing list