2 * Label printer filter for CUPS.
4 * Copyright 2007-2015 by Apple Inc.
5 * Copyright 2001-2007 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Apple Inc. and are protected by Federal copyright
9 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 * which should have been included with this file. If this file is
11 * file is missing or damaged, see the license at "http://www.cups.org/".
13 * This file is subject to the Apple OS-Developed Software exception.
17 * Include necessary headers...
20 #include <cups/cups.h>
22 #include <cups/string-private.h>
23 #include <cups/language-private.h>
24 #include <cups/raster.h>
31 * This driver filter currently supports Dymo, Intellitech, and Zebra
34 * The Dymo portion of the driver has been tested with the 300, 330,
35 * and 330 Turbo label printers; it may also work with other models.
36 * The Dymo printers support printing at 136, 203, and 300 DPI.
38 * The Intellitech portion of the driver has been tested with the
39 * Intellibar 408, 412, and 808 and supports their PCL variant.
41 * The Zebra portion of the driver has been tested with the LP-2844,
42 * LP-2844Z, QL-320, and QL-420 label printers; it may also work with
43 * other models. The driver supports EPL line mode, EPL page mode,
44 * ZPL, and CPCL as defined in Zebra's online developer documentation.
48 * Model number constants...
51 #define DYMO_3x0 0 /* Dymo Labelwriter 300/330/330 Turbo */
53 #define ZEBRA_EPL_LINE 0x10 /* Zebra EPL line mode printers */
54 #define ZEBRA_EPL_PAGE 0x11 /* Zebra EPL page mode printers */
55 #define ZEBRA_ZPL 0x12 /* Zebra ZPL-based printers */
56 #define ZEBRA_CPCL 0x13 /* Zebra CPCL-based printers */
58 #define INTELLITECH_PCL 0x20 /* Intellitech PCL-based printers */
65 unsigned char *Buffer
; /* Output buffer */
66 unsigned char *CompBuffer
; /* Compression buffer */
67 unsigned char *LastBuffer
; /* Last buffer */
68 unsigned Feed
; /* Number of lines to skip */
69 int LastSet
; /* Number of repeat characters */
70 int ModelNumber
, /* cupsModelNumber attribute */
71 Page
, /* Current page */
72 Canceled
; /* Non-zero if job is canceled */
79 void Setup(ppd_file_t
*ppd
);
80 void StartPage(ppd_file_t
*ppd
, cups_page_header2_t
*header
);
81 void EndPage(ppd_file_t
*ppd
, cups_page_header2_t
*header
);
82 void CancelJob(int sig
);
83 void OutputLine(ppd_file_t
*ppd
, cups_page_header2_t
*header
, unsigned y
);
84 void PCLCompress(unsigned char *line
, unsigned length
);
85 void ZPLCompress(unsigned char repeat_char
, unsigned repeat_count
);
89 * 'Setup()' - Prepare the printer for printing.
93 Setup(ppd_file_t
*ppd
) /* I - PPD file */
95 int i
; /* Looping var */
99 * Get the model number from the PPD file...
103 ModelNumber
= ppd
->model_number
;
106 * Initialize based on the model number...
113 * Clear any remaining data...
116 for (i
= 0; i
< 100; i
++)
120 * Reset the printer...
123 fputs("\033@", stdout
);
126 case ZEBRA_EPL_LINE
:
129 case ZEBRA_EPL_PAGE
:
138 case INTELLITECH_PCL
:
140 * Send a PCL reset sequence.
151 * 'StartPage()' - Start a page of graphics.
155 StartPage(ppd_file_t
*ppd
, /* I - PPD file */
156 cups_page_header2_t
*header
) /* I - Page header */
158 ppd_choice_t
*choice
; /* Marked choice */
159 unsigned length
; /* Actual label length */
163 * Show page device dictionary...
166 fprintf(stderr
, "DEBUG: StartPage...\n");
167 fprintf(stderr
, "DEBUG: Duplex = %d\n", header
->Duplex
);
168 fprintf(stderr
, "DEBUG: HWResolution = [ %d %d ]\n", header
->HWResolution
[0], header
->HWResolution
[1]);
169 fprintf(stderr
, "DEBUG: ImagingBoundingBox = [ %d %d %d %d ]\n", header
->ImagingBoundingBox
[0], header
->ImagingBoundingBox
[1], header
->ImagingBoundingBox
[2], header
->ImagingBoundingBox
[3]);
170 fprintf(stderr
, "DEBUG: Margins = [ %d %d ]\n", header
->Margins
[0], header
->Margins
[1]);
171 fprintf(stderr
, "DEBUG: ManualFeed = %d\n", header
->ManualFeed
);
172 fprintf(stderr
, "DEBUG: MediaPosition = %d\n", header
->MediaPosition
);
173 fprintf(stderr
, "DEBUG: NumCopies = %d\n", header
->NumCopies
);
174 fprintf(stderr
, "DEBUG: Orientation = %d\n", header
->Orientation
);
175 fprintf(stderr
, "DEBUG: PageSize = [ %d %d ]\n", header
->PageSize
[0], header
->PageSize
[1]);
176 fprintf(stderr
, "DEBUG: cupsWidth = %d\n", header
->cupsWidth
);
177 fprintf(stderr
, "DEBUG: cupsHeight = %d\n", header
->cupsHeight
);
178 fprintf(stderr
, "DEBUG: cupsMediaType = %d\n", header
->cupsMediaType
);
179 fprintf(stderr
, "DEBUG: cupsBitsPerColor = %d\n", header
->cupsBitsPerColor
);
180 fprintf(stderr
, "DEBUG: cupsBitsPerPixel = %d\n", header
->cupsBitsPerPixel
);
181 fprintf(stderr
, "DEBUG: cupsBytesPerLine = %d\n", header
->cupsBytesPerLine
);
182 fprintf(stderr
, "DEBUG: cupsColorOrder = %d\n", header
->cupsColorOrder
);
183 fprintf(stderr
, "DEBUG: cupsColorSpace = %d\n", header
->cupsColorSpace
);
184 fprintf(stderr
, "DEBUG: cupsCompression = %d\n", header
->cupsCompression
);
190 * Setup printer/job attributes...
193 length
= header
->PageSize
[1] * header
->HWResolution
[1] / 72;
195 printf("\033L%c%c", length
>> 8, length
);
196 printf("\033D%c", header
->cupsBytesPerLine
);
198 printf("\033%c", header
->cupsCompression
+ 'c'); /* Darkness */
201 case ZEBRA_EPL_LINE
:
206 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
207 strcmp(choice
->choice
, "Default"))
208 printf("\033S%.0f", atof(choice
->choice
) * 2.0 - 2.0);
214 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
215 printf("\033D%d", 7 * header
->cupsCompression
/ 100);
218 * Set left margin to 0...
221 fputs("\033M01", stdout
);
224 * Start buffered output...
227 fputs("\033B", stdout
);
230 case ZEBRA_EPL_PAGE
:
232 * Start a new label...
239 * Set hardware options...
242 if (!strcmp(header
->MediaType
, "Direct"))
249 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
250 strcmp(choice
->choice
, "Default"))
252 double val
= atof(choice
->choice
);
255 printf("S%.0f\n", val
);
257 printf("S%.0f\n", val
* 2.0 - 2.0);
264 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
265 printf("D%u\n", 15 * header
->cupsCompression
/ 100);
271 printf("q%u\n", (header
->cupsWidth
+ 7) & ~7U);
279 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
280 printf("~SD%02u\n", 30 * header
->cupsCompression
/ 100);
283 * Start bitmap graphics...
286 printf("~DGR:CUPS.GRF,%u,%u,\n",
287 header
->cupsHeight
* header
->cupsBytesPerLine
,
288 header
->cupsBytesPerLine
);
291 * Allocate compression buffers...
294 CompBuffer
= malloc(2 * header
->cupsBytesPerLine
+ 1);
295 LastBuffer
= malloc(header
->cupsBytesPerLine
);
304 printf("! 0 %u %u %u %u\r\n", header
->HWResolution
[0],
305 header
->HWResolution
[1], header
->cupsHeight
,
307 printf("PAGE-WIDTH %u\r\n", header
->cupsWidth
);
308 printf("PAGE-HEIGHT %u\r\n", header
->cupsWidth
);
311 case INTELLITECH_PCL
:
313 * Set the media size...
316 printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */
317 printf("\033&l0O"); /* Set portrait orientation */
319 switch (header
->PageSize
[1])
321 case 540 : /* Monarch Envelope */
322 printf("\033&l80A"); /* Set page size */
325 case 624 : /* DL Envelope */
326 printf("\033&l90A"); /* Set page size */
329 case 649 : /* C5 Envelope */
330 printf("\033&l91A"); /* Set page size */
333 case 684 : /* COM-10 Envelope */
334 printf("\033&l81A"); /* Set page size */
337 case 756 : /* Executive */
338 printf("\033&l1A"); /* Set page size */
341 case 792 : /* Letter */
342 printf("\033&l2A"); /* Set page size */
346 printf("\033&l26A"); /* Set page size */
349 case 1008 : /* Legal */
350 printf("\033&l3A"); /* Set page size */
353 default : /* Custom size */
354 printf("\033!f%uZ", header
->PageSize
[1] * 300 / 72);
358 printf("\033&l%uP", /* Set page length */
359 header
->PageSize
[1] / 12);
360 printf("\033&l0E"); /* Set top margin to 0 */
361 if (header
->NumCopies
)
362 printf("\033&l%uX", header
->NumCopies
);
363 /* Set number copies */
364 printf("\033&l0L"); /* Turn off perforation skip */
372 if (header
->cupsRowFeed
) /* inPrintRate */
373 printf("\033!p%uS", header
->cupsRowFeed
);
375 if (header
->cupsCompression
!= ~0U)
377 printf("\033&d%uA", 30 * header
->cupsCompression
/ 100 - 15);
379 if ((choice
= ppdFindMarkedChoice(ppd
, "inPrintMode")) != NULL
)
381 if (!strcmp(choice
->choice
, "Standard"))
382 fputs("\033!p0M", stdout
);
383 else if (!strcmp(choice
->choice
, "Tear"))
385 fputs("\033!p1M", stdout
);
387 if (header
->cupsRowCount
) /* inTearInterval */
388 printf("\033!n%uT", header
->cupsRowCount
);
392 fputs("\033!p2M", stdout
);
394 if (header
->cupsRowStep
) /* inCutInterval */
395 printf("\033!n%uC", header
->cupsRowStep
);
404 printf("\033*t%uR", header
->HWResolution
[0]);
407 printf("\033*r%uS", header
->cupsWidth
);
409 printf("\033*r%uT", header
->cupsHeight
);
412 printf("\033&a0H"); /* Set horizontal position */
413 printf("\033&a0V"); /* Set vertical position */
414 printf("\033*r1A"); /* Start graphics */
415 printf("\033*b3M"); /* Set compression */
418 * Allocate compression buffers...
421 CompBuffer
= malloc(2 * header
->cupsBytesPerLine
+ 1);
422 LastBuffer
= malloc(header
->cupsBytesPerLine
);
428 * Allocate memory for a line of graphics...
431 Buffer
= malloc(header
->cupsBytesPerLine
);
437 * 'EndPage()' - Finish a page of graphics.
441 EndPage(ppd_file_t
*ppd
, /* I - PPD file */
442 cups_page_header2_t
*header
) /* I - Page header */
444 int val
; /* Option value */
445 ppd_choice_t
*choice
; /* Marked choice */
452 * Eject the current page...
455 fputs("\033E", stdout
);
458 case ZEBRA_EPL_LINE
:
460 * End buffered output, eject the label...
463 fputs("\033E\014", stdout
);
466 case ZEBRA_EPL_PAGE
:
474 * Cut the label as needed...
477 if (header
->CutMedia
)
485 * Cancel bitmap download...
502 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
503 strcmp(choice
->choice
, "Default"))
505 val
= atoi(choice
->choice
);
506 printf("^PR%d,%d,%d\n", val
, val
, val
);
510 * Put label home in default position (0,0)...
516 * Set media tracking...
519 if (ppdIsMarked(ppd
, "zeMediaTracking", "Continuous"))
522 * Add label length command for continuous...
525 printf("^LL%d\n", header
->cupsHeight
);
528 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Web"))
530 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Mark"))
537 if (header
->cupsRowStep
!= 200)
538 printf("^LT%d\n", header
->cupsRowStep
);
544 if (!strcmp(header
->MediaType
, "Thermal"))
546 else if (!strcmp(header
->MediaType
, "Direct"))
553 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintMode")) != NULL
&&
554 strcmp(choice
->choice
, "Saved"))
558 if (!strcmp(choice
->choice
, "Tear"))
560 else if (!strcmp(choice
->choice
, "Peel"))
562 else if (!strcmp(choice
->choice
, "Rewind"))
564 else if (!strcmp(choice
->choice
, "Applicator"))
571 * Set tear-off adjust position...
574 if (header
->AdvanceDistance
!= 1000)
576 if ((int)header
->AdvanceDistance
< 0)
577 printf("~TA%04d\n", (int)header
->AdvanceDistance
);
579 printf("~TA%03d\n", (int)header
->AdvanceDistance
);
583 * Allow for reprinting after an error...
586 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
588 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
592 * Print multiple copies
595 if (header
->NumCopies
> 1)
596 printf("^PQ%d, 0, 0, N\n", header
->NumCopies
);
599 * Display the label image...
602 puts("^FO0,0^XGR:CUPS.GRF,1,1^FS");
605 * End the label and eject...
608 puts("^IDR:CUPS.GRF^FS");
612 * Cut the label as needed...
615 if (header
->CutMedia
)
621 * Set tear-off adjust position...
624 if (header
->AdvanceDistance
!= 1000)
625 printf("PRESENT-AT %d 1\r\n", (int)header
->AdvanceDistance
);
628 * Allow for reprinting after an error...
631 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
632 puts("ON-OUT-OF-PAPER WAIT\r");
633 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
634 puts("ON-OUT-OF-PAPER PURGE\r");
640 if (header
->CutMedia
)
647 if (header
->cupsCompression
> 0)
648 printf("TONE %u\r\n", 2 * header
->cupsCompression
);
654 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
655 strcmp(choice
->choice
, "Default"))
657 val
= atoi(choice
->choice
);
658 printf("SPEED %d\r\n", val
);
665 if ((choice
= ppdFindMarkedChoice(ppd
, "zeMediaTracking")) == NULL
||
666 strcmp(choice
->choice
, "Continuous"))
672 case INTELLITECH_PCL
:
673 printf("\033*rB"); /* End GFX */
674 printf("\014"); /* Eject current page */
701 * 'CancelJob()' - Cancel the current job...
705 CancelJob(int sig
) /* I - Signal */
708 * Tell the main loop to stop...
718 * 'OutputLine()' - Output a line of graphics...
722 OutputLine(ppd_file_t
*ppd
, /* I - PPD file */
723 cups_page_header2_t
*header
, /* I - Page header */
724 unsigned y
) /* I - Line number */
726 unsigned i
; /* Looping var */
727 unsigned char *ptr
; /* Pointer into buffer */
728 unsigned char *compptr
; /* Pointer into compression buffer */
729 unsigned char repeat_char
; /* Repeated character */
730 unsigned repeat_count
; /* Number of repeated characters */
731 static const unsigned char *hex
= (const unsigned char *)"0123456789ABCDEF";
741 * See if the line is blank; if not, write it to the printer...
745 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
751 printf("\033f\001%c", 255);
755 printf("\033f\001%c", Feed
);
760 fwrite(Buffer
, header
->cupsBytesPerLine
, 1, stdout
);
767 case ZEBRA_EPL_LINE
:
768 printf("\033g%03d", header
->cupsBytesPerLine
);
769 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
773 case ZEBRA_EPL_PAGE
:
774 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
776 printf("GW0,%d,%d,1\n", y
, header
->cupsBytesPerLine
);
777 for (i
= header
->cupsBytesPerLine
, ptr
= Buffer
; i
> 0; i
--, ptr
++)
786 * Determine if this row is the same as the previous line.
787 * If so, output a ':' and return...
792 if (!memcmp(Buffer
, LastBuffer
, header
->cupsBytesPerLine
))
800 * Convert the line to hex digits...
803 for (ptr
= Buffer
, compptr
= CompBuffer
, i
= header
->cupsBytesPerLine
;
807 *compptr
++ = hex
[*ptr
>> 4];
808 *compptr
++ = hex
[*ptr
& 15];
814 * Run-length compress the graphics...
817 for (compptr
= CompBuffer
+ 1, repeat_char
= CompBuffer
[0], repeat_count
= 1;
820 if (*compptr
== repeat_char
)
824 ZPLCompress(repeat_char
, repeat_count
);
825 repeat_char
= *compptr
;
829 if (repeat_char
== '0')
832 * Handle 0's on the end of the line...
835 if (repeat_count
& 1)
841 if (repeat_count
> 0)
845 ZPLCompress(repeat_char
, repeat_count
);
850 * Save this line for the next round...
853 memcpy(LastBuffer
, Buffer
, header
->cupsBytesPerLine
);
858 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
860 printf("CG %u 1 0 %d ", header
->cupsBytesPerLine
, y
);
861 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
867 case INTELLITECH_PCL
:
869 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
873 printf("\033*b%dY", Feed
);
878 PCLCompress(Buffer
, header
->cupsBytesPerLine
);
888 * 'PCLCompress()' - Output a PCL (mode 3) compressed line.
892 PCLCompress(unsigned char *line
, /* I - Line to compress */
893 unsigned length
) /* I - Length of line */
895 unsigned char *line_ptr
, /* Current byte pointer */
896 *line_end
, /* End-of-line byte pointer */
897 *comp_ptr
, /* Pointer into compression buffer */
898 *start
, /* Start of compression sequence */
899 *seed
; /* Seed buffer pointer */
900 unsigned count
, /* Count of bytes for output */
901 offset
; /* Offset of bytes for output */
905 * Do delta-row compression...
909 line_end
= line
+ length
;
911 comp_ptr
= CompBuffer
;
914 while (line_ptr
< line_end
)
917 * Find the next non-matching sequence...
925 * The seed buffer is invalid, so do the next 8 bytes, max...
930 if ((count
= (unsigned)(line_end
- line_ptr
)) > 8)
938 * The seed buffer is valid, so compare against it...
941 while (*line_ptr
== *seed
&&
948 if (line_ptr
== line_end
)
951 offset
= (unsigned)(line_ptr
- start
);
954 * Find up to 8 non-matching bytes...
959 while (*line_ptr
!= *seed
&&
960 line_ptr
< line_end
&&
970 * Place mode 3 compression data in the buffer; see HP manuals
977 * Output multi-byte offset...
980 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | 31);
983 while (offset
>= 255)
989 *comp_ptr
++ = (unsigned char)offset
;
994 * Output single-byte offset...
997 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | offset
);
1000 memcpy(comp_ptr
, start
, count
);
1005 * Set the length of the data and write it...
1008 printf("\033*b%dW", (int)(comp_ptr
- CompBuffer
));
1009 fwrite(CompBuffer
, (size_t)(comp_ptr
- CompBuffer
), 1, stdout
);
1012 * Save this line as a "seed" buffer for the next...
1015 memcpy(LastBuffer
, line
, length
);
1021 * 'ZPLCompress()' - Output a run-length compression sequence.
1025 ZPLCompress(unsigned char repeat_char
, /* I - Character to repeat */
1026 unsigned repeat_count
) /* I - Number of repeated characters */
1028 if (repeat_count
> 1)
1031 * Print as many z's as possible - they are the largest denomination
1032 * representing 400 characters (zC stands for 400 adjacent C's)
1035 while (repeat_count
>= 400)
1038 repeat_count
-= 400;
1042 * Then print 'g' through 'y' as multiples of 20 characters...
1045 if (repeat_count
>= 20)
1047 putchar((int)('f' + repeat_count
/ 20));
1052 * Finally, print 'G' through 'Y' as 1 through 19 characters...
1055 if (repeat_count
> 0)
1056 putchar((int)('F' + repeat_count
));
1060 * Then the character to be repeated...
1063 putchar((int)repeat_char
);
1068 * 'main()' - Main entry and processing of driver.
1071 int /* O - Exit status */
1072 main(int argc
, /* I - Number of command-line arguments */
1073 char *argv
[]) /* I - Command-line arguments */
1075 int fd
; /* File descriptor */
1076 cups_raster_t
*ras
; /* Raster stream for printing */
1077 cups_page_header2_t header
; /* Page header from file */
1078 unsigned y
; /* Current line */
1079 ppd_file_t
*ppd
; /* PPD file */
1080 int num_options
; /* Number of options */
1081 cups_option_t
*options
; /* Options */
1082 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1083 struct sigaction action
; /* Actions for POSIX signals */
1084 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1088 * Make sure status messages are not buffered...
1091 setbuf(stderr
, NULL
);
1094 * Check command-line...
1097 if (argc
< 6 || argc
> 7)
1100 * We don't have the correct number of arguments; write an error message
1104 _cupsLangPrintFilter(stderr
, "ERROR",
1105 _("%s job-id user title copies options [file]"),
1111 * Open the page stream...
1116 if ((fd
= open(argv
[6], O_RDONLY
)) == -1)
1118 _cupsLangPrintError("ERROR", _("Unable to open raster file"));
1126 ras
= cupsRasterOpen(fd
, CUPS_RASTER_READ
);
1129 * Register a signal handler to eject the current page if the
1135 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
1136 sigset(SIGTERM
, CancelJob
);
1137 #elif defined(HAVE_SIGACTION)
1138 memset(&action
, 0, sizeof(action
));
1140 sigemptyset(&action
.sa_mask
);
1141 action
.sa_handler
= CancelJob
;
1142 sigaction(SIGTERM
, &action
, NULL
);
1144 signal(SIGTERM
, CancelJob
);
1145 #endif /* HAVE_SIGSET */
1148 * Open the PPD file and apply options...
1151 num_options
= cupsParseOptions(argv
[5], 0, &options
);
1153 ppd
= ppdOpenFile(getenv("PPD"));
1156 ppd_status_t status
; /* PPD error */
1157 int linenum
; /* Line number */
1159 _cupsLangPrintFilter(stderr
, "ERROR",
1160 _("The PPD file could not be opened."));
1162 status
= ppdLastError(&linenum
);
1164 fprintf(stderr
, "DEBUG: %s on line %d.\n", ppdErrorString(status
), linenum
);
1169 ppdMarkDefaults(ppd
);
1170 cupsMarkOptions(ppd
, num_options
, options
);
1173 * Initialize the print device...
1179 * Process pages as needed...
1184 while (cupsRasterReadHeader2(ras
, &header
))
1187 * Write a status message with the page number and number of copies.
1195 fprintf(stderr
, "PAGE: %d 1\n", Page
);
1196 _cupsLangPrintFilter(stderr
, "INFO", _("Starting page %d."), Page
);
1202 StartPage(ppd
, &header
);
1205 * Loop for each line on the page...
1208 for (y
= 0; y
< header
.cupsHeight
&& !Canceled
; y
++)
1211 * Let the user know how far we have progressed...
1219 _cupsLangPrintFilter(stderr
, "INFO",
1220 _("Printing page %d, %u%% complete."),
1221 Page
, 100 * y
/ header
.cupsHeight
);
1222 fprintf(stderr
, "ATTR: job-media-progress=%u\n",
1223 100 * y
/ header
.cupsHeight
);
1227 * Read a line of graphics...
1230 if (cupsRasterReadPixels(ras
, Buffer
, header
.cupsBytesPerLine
) < 1)
1234 * Write it to the printer...
1237 OutputLine(ppd
, &header
, y
);
1244 _cupsLangPrintFilter(stderr
, "INFO", _("Finished page %d."), Page
);
1246 EndPage(ppd
, &header
);
1253 * Close the raster stream...
1256 cupsRasterClose(ras
);
1261 * Close the PPD file and free the options...
1265 cupsFreeOptions(num_options
, options
);
1268 * If no pages were printed, send an error message...
1273 _cupsLangPrintFilter(stderr
, "ERROR", _("No pages were found."));