Print Single PDF Page on Multiple Page Colors / Trays
pipitas at gmail.com
pipitas at gmail.com
Tue Oct 26 13:17:59 PDT 2010
> How can I submit a single job to print a page on several colors of paper?
Write your own filter or backend script. Make it so that it...
(a) ...reads + evaluates your self-invented commandline arguments "-o page-set=wpyybg"
(b) ...re-submits the job as many times as you want.
> I want to print thousands of PDF page-sets from Ubuntu. Each 'page-set' is a single page PDF, which is to be printed with a certain pattern of colored paper, say 'wpyyy' for White, Pink, Yellow, Yellow, Yellow. Generally, I keep the same pattern of page-colors for a hundred page-sets or so before changing. Each page-set has a different PDF.
>
> I'm printing from a Ruby-on-Rails app, using a fork-and-exec "system" invocation of "lpr", because the Ruby CUPS bindings are not widely used. There are two Ruby CUPS interfaces: an simple (ie 'incomplete') one from Chris Mowforth a couple of years ago, and much more comprehensive "ruby-cups-1.2" from Harald Grosse in 2002 that has little documentation, and does not readily compile on OSX. I compiled it on Snow Leopard with a couple of little changes:
> 1) Edited the Makefile and changed 'i386-s' to just 'i386'
> 2) Deleted the 'arch ppc' stuff in 3 places
>
> How can I submit a single job to print a page on several colors of paper?
> Using lpr seems to require a separate print job for each color, because you cannot use multiple "-o InputSlot" options in a single invocation:
>
> lpr -P hp4515x -o InputSlot=Tray6 f.pdf -o InputSlot=Tray3 f.pdf
You *CAN* use different input slots in a single invocation, but it will only separate the slot for the first page from the other slot used for all remaining pages of the same jobfile.
> Does Not Work - it prints "f.pdf" twice on Tray3.
>
> Sending separate print jobs for each page color causes my printer to "stall" for 4 or 5 seconds, reducing the output rate from 65ppm to 10ppm.
>
> I'd really rather render the PDF only once on the printer, and somehow tell it to print the "wpyyy" page set. Is there a way to do that in CUPS, without changing the driver's source? Which features should I investigate?
Investigate these resources:
(a) my posting from today to this newsgroup
"[Suggestion for a generic way of...] Debugging the filter chain"
http://www.cups.org/newsgroups.php?s21661+gcups.general+v21680+T0
(b) Bash code for the two example backend scripts "2file" and
"2dir" including the companion explanations
http://techbase.kde.org/Projects/KDEPrint/Tools%2BUtilities
> (Assume I know which color paper is in which tray #).
The most easy way to achieve what you want would be to...
...create a different queue for each of your white/pink/blue/...
trays and name them accordingly ("whitepaperprinter", etc.)
...set up each queue to default to the related paper tray;
...set up a queue (to send PDF jobs to) which uses a special backend.
Now you could use one of the two example scripts as a model for your special backend. For example, name your to "fanout.sh" (and put it into the "backend" directory with the correct permissions) and add a few modifications to the model:
...parse job options (seen as "${5}" for the appearance of your
"page-set=..." (self invented new CUPS commandline option for
your purpose);
...evaluate the value of that option (that's the tricky part);
...for each char in that option, send a copy of the jobfile to the
related real printer. Remove the "cat ..." lines and replace them
with print commands as needed. Ex. "page-set=wpyyy":
lp -d file -o raw whitepaperprinter
lp -d file -o raw pinkpaperprinter
lp -d file -o raw yellowpaperprinter
lp -d file -o raw yellowpaperprinter
lp -d file -o raw yellowpaperprinter
then exit your "fanout.sh" script with return value 0.
Cheers,
pipitas
More information about the cups
mailing list