2 * Label printer filter for CUPS.
4 * Copyright 2007-2016 by Apple Inc.
5 * Copyright 2001-2007 by Easy Software Products.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 * Include necessary headers...
14 #include <cups/cups.h>
16 #include <cups/string-private.h>
17 #include <cups/language-private.h>
18 #include <cups/raster.h>
25 * This driver filter currently supports Dymo, Intellitech, and Zebra
28 * The Dymo portion of the driver has been tested with the 300, 330,
29 * and 330 Turbo label printers; it may also work with other models.
30 * The Dymo printers support printing at 136, 203, and 300 DPI.
32 * The Intellitech portion of the driver has been tested with the
33 * Intellibar 408, 412, and 808 and supports their PCL variant.
35 * The Zebra portion of the driver has been tested with the LP-2844,
36 * LP-2844Z, QL-320, and QL-420 label printers; it may also work with
37 * other models. The driver supports EPL line mode, EPL page mode,
38 * ZPL, and CPCL as defined in Zebra's online developer documentation.
42 * Model number constants...
45 #define DYMO_3x0 0 /* Dymo Labelwriter 300/330/330 Turbo */
47 #define ZEBRA_EPL_LINE 0x10 /* Zebra EPL line mode printers */
48 #define ZEBRA_EPL_PAGE 0x11 /* Zebra EPL page mode printers */
49 #define ZEBRA_ZPL 0x12 /* Zebra ZPL-based printers */
50 #define ZEBRA_CPCL 0x13 /* Zebra CPCL-based printers */
52 #define INTELLITECH_PCL 0x20 /* Intellitech PCL-based printers */
59 unsigned char *Buffer
; /* Output buffer */
60 unsigned char *CompBuffer
; /* Compression buffer */
61 unsigned char *LastBuffer
; /* Last buffer */
62 unsigned Feed
; /* Number of lines to skip */
63 int LastSet
; /* Number of repeat characters */
64 int ModelNumber
, /* cupsModelNumber attribute */
65 Page
, /* Current page */
66 Canceled
; /* Non-zero if job is canceled */
73 void Setup(ppd_file_t
*ppd
);
74 void StartPage(ppd_file_t
*ppd
, cups_page_header2_t
*header
);
75 void EndPage(ppd_file_t
*ppd
, cups_page_header2_t
*header
);
76 void CancelJob(int sig
);
77 void OutputLine(ppd_file_t
*ppd
, cups_page_header2_t
*header
, unsigned y
);
78 void PCLCompress(unsigned char *line
, unsigned length
);
79 void ZPLCompress(unsigned char repeat_char
, unsigned repeat_count
);
83 * 'Setup()' - Prepare the printer for printing.
87 Setup(ppd_file_t
*ppd
) /* I - PPD file */
89 int i
; /* Looping var */
93 * Get the model number from the PPD file...
97 ModelNumber
= ppd
->model_number
;
100 * Initialize based on the model number...
107 * Clear any remaining data...
110 for (i
= 0; i
< 100; i
++)
114 * Reset the printer...
117 fputs("\033@", stdout
);
120 case ZEBRA_EPL_LINE
:
123 case ZEBRA_EPL_PAGE
:
132 case INTELLITECH_PCL
:
134 * Send a PCL reset sequence.
145 * 'StartPage()' - Start a page of graphics.
149 StartPage(ppd_file_t
*ppd
, /* I - PPD file */
150 cups_page_header2_t
*header
) /* I - Page header */
152 ppd_choice_t
*choice
; /* Marked choice */
153 unsigned length
; /* Actual label length */
157 * Show page device dictionary...
160 fprintf(stderr
, "DEBUG: StartPage...\n");
161 fprintf(stderr
, "DEBUG: Duplex = %d\n", header
->Duplex
);
162 fprintf(stderr
, "DEBUG: HWResolution = [ %d %d ]\n", header
->HWResolution
[0], header
->HWResolution
[1]);
163 fprintf(stderr
, "DEBUG: ImagingBoundingBox = [ %d %d %d %d ]\n", header
->ImagingBoundingBox
[0], header
->ImagingBoundingBox
[1], header
->ImagingBoundingBox
[2], header
->ImagingBoundingBox
[3]);
164 fprintf(stderr
, "DEBUG: Margins = [ %d %d ]\n", header
->Margins
[0], header
->Margins
[1]);
165 fprintf(stderr
, "DEBUG: ManualFeed = %d\n", header
->ManualFeed
);
166 fprintf(stderr
, "DEBUG: MediaPosition = %d\n", header
->MediaPosition
);
167 fprintf(stderr
, "DEBUG: NumCopies = %d\n", header
->NumCopies
);
168 fprintf(stderr
, "DEBUG: Orientation = %d\n", header
->Orientation
);
169 fprintf(stderr
, "DEBUG: PageSize = [ %d %d ]\n", header
->PageSize
[0], header
->PageSize
[1]);
170 fprintf(stderr
, "DEBUG: cupsWidth = %d\n", header
->cupsWidth
);
171 fprintf(stderr
, "DEBUG: cupsHeight = %d\n", header
->cupsHeight
);
172 fprintf(stderr
, "DEBUG: cupsMediaType = %d\n", header
->cupsMediaType
);
173 fprintf(stderr
, "DEBUG: cupsBitsPerColor = %d\n", header
->cupsBitsPerColor
);
174 fprintf(stderr
, "DEBUG: cupsBitsPerPixel = %d\n", header
->cupsBitsPerPixel
);
175 fprintf(stderr
, "DEBUG: cupsBytesPerLine = %d\n", header
->cupsBytesPerLine
);
176 fprintf(stderr
, "DEBUG: cupsColorOrder = %d\n", header
->cupsColorOrder
);
177 fprintf(stderr
, "DEBUG: cupsColorSpace = %d\n", header
->cupsColorSpace
);
178 fprintf(stderr
, "DEBUG: cupsCompression = %d\n", header
->cupsCompression
);
184 * Setup printer/job attributes...
187 length
= header
->PageSize
[1] * header
->HWResolution
[1] / 72;
189 printf("\033L%c%c", length
>> 8, length
);
190 printf("\033D%c", header
->cupsBytesPerLine
);
192 printf("\033%c", header
->cupsCompression
+ 'c'); /* Darkness */
195 case ZEBRA_EPL_LINE
:
200 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
201 strcmp(choice
->choice
, "Default"))
202 printf("\033S%.0f", atof(choice
->choice
) * 2.0 - 2.0);
208 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
209 printf("\033D%d", 7 * header
->cupsCompression
/ 100);
212 * Set left margin to 0...
215 fputs("\033M01", stdout
);
218 * Start buffered output...
221 fputs("\033B", stdout
);
224 case ZEBRA_EPL_PAGE
:
226 * Start a new label...
233 * Set hardware options...
236 if (!strcmp(header
->MediaType
, "Direct"))
243 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
244 strcmp(choice
->choice
, "Default"))
246 double val
= atof(choice
->choice
);
249 printf("S%.0f\n", val
);
251 printf("S%.0f\n", val
* 2.0 - 2.0);
258 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
259 printf("D%u\n", 15 * header
->cupsCompression
/ 100);
265 printf("q%u\n", (header
->cupsWidth
+ 7) & ~7U);
273 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
274 printf("~SD%02u\n", 30 * header
->cupsCompression
/ 100);
277 * Start bitmap graphics...
280 printf("~DGR:CUPS.GRF,%u,%u,\n",
281 header
->cupsHeight
* header
->cupsBytesPerLine
,
282 header
->cupsBytesPerLine
);
285 * Allocate compression buffers...
288 CompBuffer
= malloc(2 * header
->cupsBytesPerLine
+ 1);
289 LastBuffer
= malloc(header
->cupsBytesPerLine
);
298 printf("! 0 %u %u %u %u\r\n", header
->HWResolution
[0],
299 header
->HWResolution
[1], header
->cupsHeight
,
301 printf("PAGE-WIDTH %u\r\n", header
->cupsWidth
);
302 printf("PAGE-HEIGHT %u\r\n", header
->cupsHeight
);
305 case INTELLITECH_PCL
:
307 * Set the media size...
310 printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */
311 printf("\033&l0O"); /* Set portrait orientation */
313 switch (header
->PageSize
[1])
315 case 540 : /* Monarch Envelope */
316 printf("\033&l80A"); /* Set page size */
319 case 624 : /* DL Envelope */
320 printf("\033&l90A"); /* Set page size */
323 case 649 : /* C5 Envelope */
324 printf("\033&l91A"); /* Set page size */
327 case 684 : /* COM-10 Envelope */
328 printf("\033&l81A"); /* Set page size */
331 case 756 : /* Executive */
332 printf("\033&l1A"); /* Set page size */
335 case 792 : /* Letter */
336 printf("\033&l2A"); /* Set page size */
340 printf("\033&l26A"); /* Set page size */
343 case 1008 : /* Legal */
344 printf("\033&l3A"); /* Set page size */
347 default : /* Custom size */
348 printf("\033!f%uZ", header
->PageSize
[1] * 300 / 72);
352 printf("\033&l%uP", /* Set page length */
353 header
->PageSize
[1] / 12);
354 printf("\033&l0E"); /* Set top margin to 0 */
355 if (header
->NumCopies
)
356 printf("\033&l%uX", header
->NumCopies
);
357 /* Set number copies */
358 printf("\033&l0L"); /* Turn off perforation skip */
366 if (header
->cupsRowFeed
) /* inPrintRate */
367 printf("\033!p%uS", header
->cupsRowFeed
);
369 if (header
->cupsCompression
!= ~0U)
371 printf("\033&d%dA", 30 * header
->cupsCompression
/ 100 - 15);
373 if ((choice
= ppdFindMarkedChoice(ppd
, "inPrintMode")) != NULL
)
375 if (!strcmp(choice
->choice
, "Standard"))
376 fputs("\033!p0M", stdout
);
377 else if (!strcmp(choice
->choice
, "Tear"))
379 fputs("\033!p1M", stdout
);
381 if (header
->cupsRowCount
) /* inTearInterval */
382 printf("\033!n%uT", header
->cupsRowCount
);
386 fputs("\033!p2M", stdout
);
388 if (header
->cupsRowStep
) /* inCutInterval */
389 printf("\033!n%uC", header
->cupsRowStep
);
398 printf("\033*t%uR", header
->HWResolution
[0]);
401 printf("\033*r%uS", header
->cupsWidth
);
403 printf("\033*r%uT", header
->cupsHeight
);
406 printf("\033&a0H"); /* Set horizontal position */
407 printf("\033&a0V"); /* Set vertical position */
408 printf("\033*r1A"); /* Start graphics */
409 printf("\033*b3M"); /* Set compression */
412 * Allocate compression buffers...
415 CompBuffer
= malloc(2 * header
->cupsBytesPerLine
+ 1);
416 LastBuffer
= malloc(header
->cupsBytesPerLine
);
422 * Allocate memory for a line of graphics...
425 Buffer
= malloc(header
->cupsBytesPerLine
);
431 * 'EndPage()' - Finish a page of graphics.
435 EndPage(ppd_file_t
*ppd
, /* I - PPD file */
436 cups_page_header2_t
*header
) /* I - Page header */
438 int val
; /* Option value */
439 ppd_choice_t
*choice
; /* Marked choice */
446 * Eject the current page...
449 fputs("\033E", stdout
);
452 case ZEBRA_EPL_LINE
:
454 * End buffered output, eject the label...
457 fputs("\033E\014", stdout
);
460 case ZEBRA_EPL_PAGE
:
468 * Cut the label as needed...
471 if (header
->CutMedia
)
479 * Cancel bitmap download...
493 * Rotate 180 degrees so that the top of the label/page is at the
503 printf("^PW%u\n", header
->cupsWidth
);
509 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
510 strcmp(choice
->choice
, "Default"))
512 val
= atoi(choice
->choice
);
513 printf("^PR%d,%d,%d\n", val
, val
, val
);
517 * Put label home in default position (0,0)...
523 * Set media tracking...
526 if (ppdIsMarked(ppd
, "zeMediaTracking", "Continuous"))
529 * Add label length command for continuous...
532 printf("^LL%d\n", header
->cupsHeight
);
535 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Web"))
537 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Mark"))
544 if (header
->cupsRowStep
!= 200)
545 printf("^LT%d\n", header
->cupsRowStep
);
551 if (!strcmp(header
->MediaType
, "Thermal"))
553 else if (!strcmp(header
->MediaType
, "Direct"))
560 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintMode")) != NULL
&&
561 strcmp(choice
->choice
, "Saved"))
565 if (!strcmp(choice
->choice
, "Tear"))
567 else if (!strcmp(choice
->choice
, "Peel"))
569 else if (!strcmp(choice
->choice
, "Rewind"))
571 else if (!strcmp(choice
->choice
, "Applicator"))
578 * Set tear-off adjust position...
581 if (header
->AdvanceDistance
!= 1000)
583 if ((int)header
->AdvanceDistance
< 0)
584 printf("~TA%04d\n", (int)header
->AdvanceDistance
);
586 printf("~TA%03d\n", (int)header
->AdvanceDistance
);
590 * Allow for reprinting after an error...
593 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
595 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
599 * Print multiple copies
602 if (header
->NumCopies
> 1)
603 printf("^PQ%d, 0, 0, N\n", header
->NumCopies
);
606 * Display the label image...
609 puts("^FO0,0^XGR:CUPS.GRF,1,1^FS");
612 * End the label and eject...
616 puts("^IDR:CUPS.GRF^FS");
619 * Cut the label as needed...
622 if (header
->CutMedia
)
628 * Set tear-off adjust position...
631 if (header
->AdvanceDistance
!= 1000)
632 printf("PRESENT-AT %d 1\r\n", (int)header
->AdvanceDistance
);
635 * Allow for reprinting after an error...
638 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
639 puts("ON-OUT-OF-PAPER WAIT\r");
640 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
641 puts("ON-OUT-OF-PAPER PURGE\r");
647 if (header
->CutMedia
)
654 if (header
->cupsCompression
> 0)
655 printf("TONE %u\r\n", 2 * header
->cupsCompression
);
661 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
662 strcmp(choice
->choice
, "Default"))
664 val
= atoi(choice
->choice
);
665 printf("SPEED %d\r\n", val
);
672 if ((choice
= ppdFindMarkedChoice(ppd
, "zeMediaTracking")) == NULL
||
673 strcmp(choice
->choice
, "Continuous"))
679 case INTELLITECH_PCL
:
680 printf("\033*rB"); /* End GFX */
681 printf("\014"); /* Eject current page */
708 * 'CancelJob()' - Cancel the current job...
712 CancelJob(int sig
) /* I - Signal */
715 * Tell the main loop to stop...
725 * 'OutputLine()' - Output a line of graphics...
729 OutputLine(ppd_file_t
*ppd
, /* I - PPD file */
730 cups_page_header2_t
*header
, /* I - Page header */
731 unsigned y
) /* I - Line number */
733 unsigned i
; /* Looping var */
734 unsigned char *ptr
; /* Pointer into buffer */
735 unsigned char *compptr
; /* Pointer into compression buffer */
736 unsigned char repeat_char
; /* Repeated character */
737 unsigned repeat_count
; /* Number of repeated characters */
738 static const unsigned char *hex
= (const unsigned char *)"0123456789ABCDEF";
748 * See if the line is blank; if not, write it to the printer...
752 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
758 printf("\033f\001%c", 255);
762 printf("\033f\001%c", Feed
);
767 fwrite(Buffer
, header
->cupsBytesPerLine
, 1, stdout
);
774 case ZEBRA_EPL_LINE
:
775 printf("\033g%03d", header
->cupsBytesPerLine
);
776 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
780 case ZEBRA_EPL_PAGE
:
781 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
783 printf("GW0,%d,%d,1\n", y
, header
->cupsBytesPerLine
);
784 for (i
= header
->cupsBytesPerLine
, ptr
= Buffer
; i
> 0; i
--, ptr
++)
793 * Determine if this row is the same as the previous line.
794 * If so, output a ':' and return...
799 if (!memcmp(Buffer
, LastBuffer
, header
->cupsBytesPerLine
))
807 * Convert the line to hex digits...
810 for (ptr
= Buffer
, compptr
= CompBuffer
, i
= header
->cupsBytesPerLine
;
814 *compptr
++ = hex
[*ptr
>> 4];
815 *compptr
++ = hex
[*ptr
& 15];
821 * Run-length compress the graphics...
824 for (compptr
= CompBuffer
+ 1, repeat_char
= CompBuffer
[0], repeat_count
= 1;
827 if (*compptr
== repeat_char
)
831 ZPLCompress(repeat_char
, repeat_count
);
832 repeat_char
= *compptr
;
836 if (repeat_char
== '0')
839 * Handle 0's on the end of the line...
842 if (repeat_count
& 1)
848 if (repeat_count
> 0)
852 ZPLCompress(repeat_char
, repeat_count
);
857 * Save this line for the next round...
860 memcpy(LastBuffer
, Buffer
, header
->cupsBytesPerLine
);
865 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
867 printf("CG %u 1 0 %d ", header
->cupsBytesPerLine
, y
);
868 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
874 case INTELLITECH_PCL
:
876 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
880 printf("\033*b%dY", Feed
);
885 PCLCompress(Buffer
, header
->cupsBytesPerLine
);
895 * 'PCLCompress()' - Output a PCL (mode 3) compressed line.
899 PCLCompress(unsigned char *line
, /* I - Line to compress */
900 unsigned length
) /* I - Length of line */
902 unsigned char *line_ptr
, /* Current byte pointer */
903 *line_end
, /* End-of-line byte pointer */
904 *comp_ptr
, /* Pointer into compression buffer */
905 *start
, /* Start of compression sequence */
906 *seed
; /* Seed buffer pointer */
907 unsigned count
, /* Count of bytes for output */
908 offset
; /* Offset of bytes for output */
912 * Do delta-row compression...
916 line_end
= line
+ length
;
918 comp_ptr
= CompBuffer
;
921 while (line_ptr
< line_end
)
924 * Find the next non-matching sequence...
932 * The seed buffer is invalid, so do the next 8 bytes, max...
937 if ((count
= (unsigned)(line_end
- line_ptr
)) > 8)
945 * The seed buffer is valid, so compare against it...
948 while (*line_ptr
== *seed
&&
955 if (line_ptr
== line_end
)
958 offset
= (unsigned)(line_ptr
- start
);
961 * Find up to 8 non-matching bytes...
966 while (*line_ptr
!= *seed
&&
967 line_ptr
< line_end
&&
977 * Place mode 3 compression data in the buffer; see HP manuals
984 * Output multi-byte offset...
987 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | 31);
990 while (offset
>= 255)
996 *comp_ptr
++ = (unsigned char)offset
;
1001 * Output single-byte offset...
1004 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | offset
);
1007 memcpy(comp_ptr
, start
, count
);
1012 * Set the length of the data and write it...
1015 printf("\033*b%dW", (int)(comp_ptr
- CompBuffer
));
1016 fwrite(CompBuffer
, (size_t)(comp_ptr
- CompBuffer
), 1, stdout
);
1019 * Save this line as a "seed" buffer for the next...
1022 memcpy(LastBuffer
, line
, length
);
1028 * 'ZPLCompress()' - Output a run-length compression sequence.
1032 ZPLCompress(unsigned char repeat_char
, /* I - Character to repeat */
1033 unsigned repeat_count
) /* I - Number of repeated characters */
1035 if (repeat_count
> 1)
1038 * Print as many z's as possible - they are the largest denomination
1039 * representing 400 characters (zC stands for 400 adjacent C's)
1042 while (repeat_count
>= 400)
1045 repeat_count
-= 400;
1049 * Then print 'g' through 'y' as multiples of 20 characters...
1052 if (repeat_count
>= 20)
1054 putchar((int)('f' + repeat_count
/ 20));
1059 * Finally, print 'G' through 'Y' as 1 through 19 characters...
1062 if (repeat_count
> 0)
1063 putchar((int)('F' + repeat_count
));
1067 * Then the character to be repeated...
1070 putchar((int)repeat_char
);
1075 * 'main()' - Main entry and processing of driver.
1078 int /* O - Exit status */
1079 main(int argc
, /* I - Number of command-line arguments */
1080 char *argv
[]) /* I - Command-line arguments */
1082 int fd
; /* File descriptor */
1083 cups_raster_t
*ras
; /* Raster stream for printing */
1084 cups_page_header2_t header
; /* Page header from file */
1085 unsigned y
; /* Current line */
1086 ppd_file_t
*ppd
; /* PPD file */
1087 int num_options
; /* Number of options */
1088 cups_option_t
*options
; /* Options */
1089 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1090 struct sigaction action
; /* Actions for POSIX signals */
1091 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1095 * Make sure status messages are not buffered...
1098 setbuf(stderr
, NULL
);
1101 * Check command-line...
1104 if (argc
< 6 || argc
> 7)
1107 * We don't have the correct number of arguments; write an error message
1111 _cupsLangPrintFilter(stderr
, "ERROR",
1112 _("%s job-id user title copies options [file]"),
1118 * Open the page stream...
1123 if ((fd
= open(argv
[6], O_RDONLY
)) == -1)
1125 _cupsLangPrintError("ERROR", _("Unable to open raster file"));
1133 ras
= cupsRasterOpen(fd
, CUPS_RASTER_READ
);
1136 * Register a signal handler to eject the current page if the
1142 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
1143 sigset(SIGTERM
, CancelJob
);
1144 #elif defined(HAVE_SIGACTION)
1145 memset(&action
, 0, sizeof(action
));
1147 sigemptyset(&action
.sa_mask
);
1148 action
.sa_handler
= CancelJob
;
1149 sigaction(SIGTERM
, &action
, NULL
);
1151 signal(SIGTERM
, CancelJob
);
1152 #endif /* HAVE_SIGSET */
1155 * Open the PPD file and apply options...
1158 num_options
= cupsParseOptions(argv
[5], 0, &options
);
1160 ppd
= ppdOpenFile(getenv("PPD"));
1163 ppd_status_t status
; /* PPD error */
1164 int linenum
; /* Line number */
1166 _cupsLangPrintFilter(stderr
, "ERROR",
1167 _("The PPD file could not be opened."));
1169 status
= ppdLastError(&linenum
);
1171 fprintf(stderr
, "DEBUG: %s on line %d.\n", ppdErrorString(status
), linenum
);
1176 ppdMarkDefaults(ppd
);
1177 cupsMarkOptions(ppd
, num_options
, options
);
1180 * Initialize the print device...
1186 * Process pages as needed...
1191 while (cupsRasterReadHeader2(ras
, &header
))
1194 * Write a status message with the page number and number of copies.
1202 fprintf(stderr
, "PAGE: %d 1\n", Page
);
1203 _cupsLangPrintFilter(stderr
, "INFO", _("Starting page %d."), Page
);
1209 StartPage(ppd
, &header
);
1212 * Loop for each line on the page...
1215 for (y
= 0; y
< header
.cupsHeight
&& !Canceled
; y
++)
1218 * Let the user know how far we have progressed...
1226 _cupsLangPrintFilter(stderr
, "INFO",
1227 _("Printing page %d, %u%% complete."),
1228 Page
, 100 * y
/ header
.cupsHeight
);
1229 fprintf(stderr
, "ATTR: job-media-progress=%u\n",
1230 100 * y
/ header
.cupsHeight
);
1234 * Read a line of graphics...
1237 if (cupsRasterReadPixels(ras
, Buffer
, header
.cupsBytesPerLine
) < 1)
1241 * Write it to the printer...
1244 OutputLine(ppd
, &header
, y
);
1251 _cupsLangPrintFilter(stderr
, "INFO", _("Finished page %d."), Page
);
1253 EndPage(ppd
, &header
);
1260 * Close the raster stream...
1263 cupsRasterClose(ras
);
1268 * Close the PPD file and free the options...
1272 cupsFreeOptions(num_options
, options
);
1275 * If no pages were printed, send an error message...
1280 _cupsLangPrintFilter(stderr
, "ERROR", _("No pages were found."));