2 * Label printer filter for CUPS.
4 * Copyright 2007-2016 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...
499 * Rotate 180 degrees so that the top of the label/page is at the
509 printf("^PW%u\n", header
->cupsWidth
);
515 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
516 strcmp(choice
->choice
, "Default"))
518 val
= atoi(choice
->choice
);
519 printf("^PR%d,%d,%d\n", val
, val
, val
);
523 * Put label home in default position (0,0)...
529 * Set media tracking...
532 if (ppdIsMarked(ppd
, "zeMediaTracking", "Continuous"))
535 * Add label length command for continuous...
538 printf("^LL%d\n", header
->cupsHeight
);
541 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Web"))
543 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Mark"))
550 if (header
->cupsRowStep
!= 200)
551 printf("^LT%d\n", header
->cupsRowStep
);
557 if (!strcmp(header
->MediaType
, "Thermal"))
559 else if (!strcmp(header
->MediaType
, "Direct"))
566 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintMode")) != NULL
&&
567 strcmp(choice
->choice
, "Saved"))
571 if (!strcmp(choice
->choice
, "Tear"))
573 else if (!strcmp(choice
->choice
, "Peel"))
575 else if (!strcmp(choice
->choice
, "Rewind"))
577 else if (!strcmp(choice
->choice
, "Applicator"))
584 * Set tear-off adjust position...
587 if (header
->AdvanceDistance
!= 1000)
589 if ((int)header
->AdvanceDistance
< 0)
590 printf("~TA%04d\n", (int)header
->AdvanceDistance
);
592 printf("~TA%03d\n", (int)header
->AdvanceDistance
);
596 * Allow for reprinting after an error...
599 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
601 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
605 * Print multiple copies
608 if (header
->NumCopies
> 1)
609 printf("^PQ%d, 0, 0, N\n", header
->NumCopies
);
612 * Display the label image...
615 puts("^FO0,0^XGR:CUPS.GRF,1,1^FS");
618 * End the label and eject...
622 puts("^IDR:CUPS.GRF^FS");
625 * Cut the label as needed...
628 if (header
->CutMedia
)
634 * Set tear-off adjust position...
637 if (header
->AdvanceDistance
!= 1000)
638 printf("PRESENT-AT %d 1\r\n", (int)header
->AdvanceDistance
);
641 * Allow for reprinting after an error...
644 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
645 puts("ON-OUT-OF-PAPER WAIT\r");
646 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
647 puts("ON-OUT-OF-PAPER PURGE\r");
653 if (header
->CutMedia
)
660 if (header
->cupsCompression
> 0)
661 printf("TONE %u\r\n", 2 * header
->cupsCompression
);
667 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
668 strcmp(choice
->choice
, "Default"))
670 val
= atoi(choice
->choice
);
671 printf("SPEED %d\r\n", val
);
678 if ((choice
= ppdFindMarkedChoice(ppd
, "zeMediaTracking")) == NULL
||
679 strcmp(choice
->choice
, "Continuous"))
685 case INTELLITECH_PCL
:
686 printf("\033*rB"); /* End GFX */
687 printf("\014"); /* Eject current page */
714 * 'CancelJob()' - Cancel the current job...
718 CancelJob(int sig
) /* I - Signal */
721 * Tell the main loop to stop...
731 * 'OutputLine()' - Output a line of graphics...
735 OutputLine(ppd_file_t
*ppd
, /* I - PPD file */
736 cups_page_header2_t
*header
, /* I - Page header */
737 unsigned y
) /* I - Line number */
739 unsigned i
; /* Looping var */
740 unsigned char *ptr
; /* Pointer into buffer */
741 unsigned char *compptr
; /* Pointer into compression buffer */
742 unsigned char repeat_char
; /* Repeated character */
743 unsigned repeat_count
; /* Number of repeated characters */
744 static const unsigned char *hex
= (const unsigned char *)"0123456789ABCDEF";
754 * See if the line is blank; if not, write it to the printer...
758 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
764 printf("\033f\001%c", 255);
768 printf("\033f\001%c", Feed
);
773 fwrite(Buffer
, header
->cupsBytesPerLine
, 1, stdout
);
780 case ZEBRA_EPL_LINE
:
781 printf("\033g%03d", header
->cupsBytesPerLine
);
782 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
786 case ZEBRA_EPL_PAGE
:
787 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
789 printf("GW0,%d,%d,1\n", y
, header
->cupsBytesPerLine
);
790 for (i
= header
->cupsBytesPerLine
, ptr
= Buffer
; i
> 0; i
--, ptr
++)
799 * Determine if this row is the same as the previous line.
800 * If so, output a ':' and return...
805 if (!memcmp(Buffer
, LastBuffer
, header
->cupsBytesPerLine
))
813 * Convert the line to hex digits...
816 for (ptr
= Buffer
, compptr
= CompBuffer
, i
= header
->cupsBytesPerLine
;
820 *compptr
++ = hex
[*ptr
>> 4];
821 *compptr
++ = hex
[*ptr
& 15];
827 * Run-length compress the graphics...
830 for (compptr
= CompBuffer
+ 1, repeat_char
= CompBuffer
[0], repeat_count
= 1;
833 if (*compptr
== repeat_char
)
837 ZPLCompress(repeat_char
, repeat_count
);
838 repeat_char
= *compptr
;
842 if (repeat_char
== '0')
845 * Handle 0's on the end of the line...
848 if (repeat_count
& 1)
854 if (repeat_count
> 0)
858 ZPLCompress(repeat_char
, repeat_count
);
863 * Save this line for the next round...
866 memcpy(LastBuffer
, Buffer
, header
->cupsBytesPerLine
);
871 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
873 printf("CG %u 1 0 %d ", header
->cupsBytesPerLine
, y
);
874 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
880 case INTELLITECH_PCL
:
882 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
886 printf("\033*b%dY", Feed
);
891 PCLCompress(Buffer
, header
->cupsBytesPerLine
);
901 * 'PCLCompress()' - Output a PCL (mode 3) compressed line.
905 PCLCompress(unsigned char *line
, /* I - Line to compress */
906 unsigned length
) /* I - Length of line */
908 unsigned char *line_ptr
, /* Current byte pointer */
909 *line_end
, /* End-of-line byte pointer */
910 *comp_ptr
, /* Pointer into compression buffer */
911 *start
, /* Start of compression sequence */
912 *seed
; /* Seed buffer pointer */
913 unsigned count
, /* Count of bytes for output */
914 offset
; /* Offset of bytes for output */
918 * Do delta-row compression...
922 line_end
= line
+ length
;
924 comp_ptr
= CompBuffer
;
927 while (line_ptr
< line_end
)
930 * Find the next non-matching sequence...
938 * The seed buffer is invalid, so do the next 8 bytes, max...
943 if ((count
= (unsigned)(line_end
- line_ptr
)) > 8)
951 * The seed buffer is valid, so compare against it...
954 while (*line_ptr
== *seed
&&
961 if (line_ptr
== line_end
)
964 offset
= (unsigned)(line_ptr
- start
);
967 * Find up to 8 non-matching bytes...
972 while (*line_ptr
!= *seed
&&
973 line_ptr
< line_end
&&
983 * Place mode 3 compression data in the buffer; see HP manuals
990 * Output multi-byte offset...
993 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | 31);
996 while (offset
>= 255)
1002 *comp_ptr
++ = (unsigned char)offset
;
1007 * Output single-byte offset...
1010 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | offset
);
1013 memcpy(comp_ptr
, start
, count
);
1018 * Set the length of the data and write it...
1021 printf("\033*b%dW", (int)(comp_ptr
- CompBuffer
));
1022 fwrite(CompBuffer
, (size_t)(comp_ptr
- CompBuffer
), 1, stdout
);
1025 * Save this line as a "seed" buffer for the next...
1028 memcpy(LastBuffer
, line
, length
);
1034 * 'ZPLCompress()' - Output a run-length compression sequence.
1038 ZPLCompress(unsigned char repeat_char
, /* I - Character to repeat */
1039 unsigned repeat_count
) /* I - Number of repeated characters */
1041 if (repeat_count
> 1)
1044 * Print as many z's as possible - they are the largest denomination
1045 * representing 400 characters (zC stands for 400 adjacent C's)
1048 while (repeat_count
>= 400)
1051 repeat_count
-= 400;
1055 * Then print 'g' through 'y' as multiples of 20 characters...
1058 if (repeat_count
>= 20)
1060 putchar((int)('f' + repeat_count
/ 20));
1065 * Finally, print 'G' through 'Y' as 1 through 19 characters...
1068 if (repeat_count
> 0)
1069 putchar((int)('F' + repeat_count
));
1073 * Then the character to be repeated...
1076 putchar((int)repeat_char
);
1081 * 'main()' - Main entry and processing of driver.
1084 int /* O - Exit status */
1085 main(int argc
, /* I - Number of command-line arguments */
1086 char *argv
[]) /* I - Command-line arguments */
1088 int fd
; /* File descriptor */
1089 cups_raster_t
*ras
; /* Raster stream for printing */
1090 cups_page_header2_t header
; /* Page header from file */
1091 unsigned y
; /* Current line */
1092 ppd_file_t
*ppd
; /* PPD file */
1093 int num_options
; /* Number of options */
1094 cups_option_t
*options
; /* Options */
1095 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1096 struct sigaction action
; /* Actions for POSIX signals */
1097 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1101 * Make sure status messages are not buffered...
1104 setbuf(stderr
, NULL
);
1107 * Check command-line...
1110 if (argc
< 6 || argc
> 7)
1113 * We don't have the correct number of arguments; write an error message
1117 _cupsLangPrintFilter(stderr
, "ERROR",
1118 _("%s job-id user title copies options [file]"),
1124 * Open the page stream...
1129 if ((fd
= open(argv
[6], O_RDONLY
)) == -1)
1131 _cupsLangPrintError("ERROR", _("Unable to open raster file"));
1139 ras
= cupsRasterOpen(fd
, CUPS_RASTER_READ
);
1142 * Register a signal handler to eject the current page if the
1148 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
1149 sigset(SIGTERM
, CancelJob
);
1150 #elif defined(HAVE_SIGACTION)
1151 memset(&action
, 0, sizeof(action
));
1153 sigemptyset(&action
.sa_mask
);
1154 action
.sa_handler
= CancelJob
;
1155 sigaction(SIGTERM
, &action
, NULL
);
1157 signal(SIGTERM
, CancelJob
);
1158 #endif /* HAVE_SIGSET */
1161 * Open the PPD file and apply options...
1164 num_options
= cupsParseOptions(argv
[5], 0, &options
);
1166 ppd
= ppdOpenFile(getenv("PPD"));
1169 ppd_status_t status
; /* PPD error */
1170 int linenum
; /* Line number */
1172 _cupsLangPrintFilter(stderr
, "ERROR",
1173 _("The PPD file could not be opened."));
1175 status
= ppdLastError(&linenum
);
1177 fprintf(stderr
, "DEBUG: %s on line %d.\n", ppdErrorString(status
), linenum
);
1182 ppdMarkDefaults(ppd
);
1183 cupsMarkOptions(ppd
, num_options
, options
);
1186 * Initialize the print device...
1192 * Process pages as needed...
1197 while (cupsRasterReadHeader2(ras
, &header
))
1200 * Write a status message with the page number and number of copies.
1208 fprintf(stderr
, "PAGE: %d 1\n", Page
);
1209 _cupsLangPrintFilter(stderr
, "INFO", _("Starting page %d."), Page
);
1215 StartPage(ppd
, &header
);
1218 * Loop for each line on the page...
1221 for (y
= 0; y
< header
.cupsHeight
&& !Canceled
; y
++)
1224 * Let the user know how far we have progressed...
1232 _cupsLangPrintFilter(stderr
, "INFO",
1233 _("Printing page %d, %u%% complete."),
1234 Page
, 100 * y
/ header
.cupsHeight
);
1235 fprintf(stderr
, "ATTR: job-media-progress=%u\n",
1236 100 * y
/ header
.cupsHeight
);
1240 * Read a line of graphics...
1243 if (cupsRasterReadPixels(ras
, Buffer
, header
.cupsBytesPerLine
) < 1)
1247 * Write it to the printer...
1250 OutputLine(ppd
, &header
, y
);
1257 _cupsLangPrintFilter(stderr
, "INFO", _("Finished page %d."), Page
);
1259 EndPage(ppd
, &header
);
1266 * Close the raster stream...
1269 cupsRasterClose(ras
);
1274 * Close the PPD file and free the options...
1278 cupsFreeOptions(num_options
, options
);
1281 * If no pages were printed, send an error message...
1286 _cupsLangPrintFilter(stderr
, "ERROR", _("No pages were found."));