Skip to content

Commit 95ab4a9

Browse files
committed
Add -n[Copies] to -z1 printers (for more efficient print job)
Copies works, but don't know about older -z0 printers, therefore left them as-is using a manual copy method.
1 parent a48c242 commit 95ab4a9

9 files changed

Lines changed: 50 additions & 15 deletions

‎PPD/Dell-1250c.ppd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*Manufacturer: "Dell"
3232
*Product: "(1250c)"
3333
*cupsVersion: 1.0
34-
*cupsManualCopies: False
34+
*cupsManualCopies: True
3535
*cupsModelNumber: 2
3636
*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"
3737
*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

‎PPD/Dell-C1660.ppd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*Manufacturer: "Dell"
3232
*Product: "(C1660)"
3333
*cupsVersion: 1.0
34-
*cupsManualCopies: False
34+
*cupsManualCopies: True
3535
*cupsModelNumber: 2
3636
*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"
3737
*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

‎PPD/Dell-C1760.ppd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*Manufacturer: "Dell"
3232
*Product: "(C1760)"
3333
*cupsVersion: 1.0
34-
*cupsManualCopies: False
34+
*cupsManualCopies: True
3535
*cupsModelNumber: 2
3636
*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"
3737
*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

‎PPD/Epson-AcuLaser_C1700.ppd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*Manufacturer: "Epson"
3232
*Product: "(AcuLaser C1700)"
3333
*cupsVersion: 1.0
34-
*cupsManualCopies: False
34+
*cupsManualCopies: True
3535
*cupsModelNumber: 2
3636
*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"
3737
*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

‎PPD/Fuji_Xerox-DocuPrint_CP105.ppd‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*Manufacturer: "Fuji Xerox"
3232
*Product: "(DocuPrint CP105)"
3333
*cupsVersion: 1.0
34-
*cupsManualCopies: False
34+
*cupsManualCopies: True
3535
*cupsModelNumber: 2
3636
*cupsFilter: "application/vnd.cups-postscript 100 foomatic-rip"
3737
*cupsFilter: "application/vnd.cups-pdf 0 foomatic-rip"

‎foo2hbpl1-wrapper.1in‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,15 @@ envDL 12
9090
.TE
9191
.TP
9292
.BI \-n\0 copies
93-
Number of copies [1].
93+
Number of copies of each page [1]. Only available for \-z1 printers.
94+
.TS
95+
l l l.
96+
_
97+
Model Range Example printer(s)
98+
_
99+
z0 \- Dell 1250c / C1660 / C1760
100+
z1 1-999 Xerox 6000 / 6010
101+
.TE
94102
.TP
95103
.BI \-r\0 xres x yres
96104
Set device resolution in pixels/inch [1200x600].

‎foo2hbpl1-wrapper.in‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,13 @@ esac
386386

387387
PAPERSIZE="-sPAPERSIZE=$PAPER";
388388

389+
# -z0 does not accept this option, -z1+ accepts -n[1..999]
390+
case "$MODEL" in
391+
0) COPIES="";;
392+
1) COPIES="-n$COPIES";;
393+
*)
394+
esac
395+
389396
#
390397
# Filter thru psnup if N-up printing has been requested
391398
#
@@ -572,7 +579,7 @@ foo2zjs-pstops $PSTOPS_OPTS | \
572579
$PREFILTER \
573580
| ($GS $PAPERSIZE -g$DIM -r$RES $GSDEV $GSOPTS \
574581
-sOutputFile="|cat 1>&3" $GAMMAFILE -_ >/dev/null) 3>&1 \
575-
| foo2hbpl1 -m$MEDIA $CLIP_ALL -J "$LPJOB" -U "$USER"
582+
| foo2hbpl1 -m$MEDIA $COPIES $CLIP_ALL -J "$LPJOB" -U "$USER"
576583

577584
#
578585
# Log the command line, for debugging and problem reports
@@ -581,7 +588,7 @@ if [ -x /usr/bin/logger ]; then
581588
logger -t "$BASENAME" -p lpr.info -- \
582589
"$GSBIN $PAPERSIZE -g$DIM -r$RES $GSDEV $GSOPTS $GAMMAFILE"
583590
logger -t "$BASENAME" -p lpr.info -- \
584-
"foo2hbpl1 -m$MEDIA $CLIP_ALL"
591+
"foo2hbpl1 -m$MEDIA $COPIES $CLIP_ALL"
585592
fi
586593

587594
#

‎foo2hbpl1.1in‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ user1 \- \- 21 22
4949
special \- \- 23 24
5050
.TE
5151
.TP
52+
.BI \-n\0 copies
53+
Number of copies of each page [1]. Only available for \-z1 printers.
54+
.TS
55+
l l l.
56+
_
57+
Model Range Example printer(s)
58+
_
59+
z0 \- Dell 1250c / C1660 / C1760
60+
z1 1-999 Xerox 6000 / 6010
61+
.TE
62+
.TP
5263
.BI \-J\0 filename
5364
Filename string to send to printer.
5465
.TP

‎foo2hbpl1.c‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static char Version[] = "$Id: foo2hbpl1.c,v 1.3 2014/03/30 05:08:32 rick Exp $";
5151
/*
5252
* Command line options
5353
*/
54+
int Copies = 1; // [1..999] Page Copies (default=1)
5455
int MediaCode = -1; // -1=undefined (default to paper)
5556
int Model = -1; // -1=undefined (default -z0)
5657
int pagenum = 0; // no pages, no printer codes sent
@@ -118,8 +119,9 @@ usage(void)
118119
" 19=color, 20=color (side2),\n"
119120
" 21=user, 22=user (side2),\n"
120121
" 23=special, 24=special (side2)\n"
121-
"-J filename Filename string to send to printer [%s]\n"
122-
"-U username Username string to send to printer [%s]\n"
122+
"-n copies Number of copies [%d]\n"
123+
"-J filename Filename string to send to printer [%s]\n"
124+
"-U username Username string to send to printer [%s]\n"
123125
"\n"
124126
"Printer Tweaking Options:\n"
125127
"-u left,top,right,bottom\n"
@@ -130,6 +132,7 @@ usage(void)
130132
"\n"
131133
"Debugging Options:\n"
132134
"-V Version %s\n"
135+
, Copies
133136
, Filename ? Filename : ""
134137
, Username ? Username : ""
135138
, Clip[0], Clip[1], Clip[2], Clip[3]
@@ -361,7 +364,7 @@ start_doc(int color)
361364
"@PJL SET JOBATTR=\"@TRAP=ON\"\n"
362365
"@PJL SET JOBATTR=\"@JOAU=%s\"\n"
363366
"@PJL SET JOBATTR=\"@CNAM=%s\"\n"
364-
"@PJL SET COPIES=1\n"
367+
"@PJL SET COPIES=%-2d\n"
365368
"@PJL SET QTY=1\n"
366369
"@PJL SET PAPERDIRECTION=SEF\n"
367370
"@PJL SET RESOLUTION=600\n"
@@ -391,7 +394,8 @@ start_doc(int color)
391394
, mname[MediaCode]
392395
, color ? "COLOR" : "GRAYSCALE"
393396
, Username ? Username : ""
394-
, cname);
397+
, cname
398+
, Copies);
395399
fwrite (reca, 1, sizeof reca, stdout);
396400

397401
pagenum++; // Now begin printing as "JOB START=1"...
@@ -491,7 +495,7 @@ encode_page(int color, int width, int height, char *image)
491495
head[21] = 2;
492496
}
493497
width = -(-width & -8);
494-
setle (head+33, 4, pagenum++);
498+
setle (head+33, 4, pagenum);
495499
setle (head+39, 4, width);
496500
setle (head+43, 4, height);
497501
setle (head+70, 4, width);
@@ -600,6 +604,7 @@ encode_page(int color, int width, int height, char *image)
600604
}
601605
free(blank-width/8-1);
602606
printf("SD");
607+
pagenum +=Copies;
603608
}
604609
#undef IP
605610
#undef CP
@@ -729,10 +734,11 @@ main(int argc, char *argv[])
729734
{
730735
int c, i;
731736

732-
while ( (c = getopt(argc, argv, "m:u:z:J:U:V")) != EOF)
737+
while ( (c = getopt(argc, argv, "m:n:u:z:J:U:V")) != EOF)
733738
switch (c)
734739
{
735740
case 'm': MediaCode = atoi(optarg); break;
741+
case 'n': Copies = atoi(optarg); break;
736742
case 'u': if (sscanf(optarg, "%d,%d,%d,%d",
737743
Clip, Clip+1, Clip+2, Clip+3) != 4)
738744
error(1, "Must specify four clipping margins!\n");
@@ -758,7 +764,10 @@ main(int argc, char *argv[])
758764
else if (MediaCode == 7) MediaCode = 1-1;
759765
}
760766
MediaCode++;
761-
767+
if (Model <= 0 && Copies !=1)
768+
error(1, "Illegal value for -n. Must be 1 for -z0 printers!\n");
769+
if (Copies < 1 || Copies > 999)
770+
error(1, "Illegal value for -n%d. Must be a number [1..999]!\n", Copies);
762771

763772
argc -= optind;
764773
argv += optind;

0 commit comments

Comments
 (0)