2 * Label printer filter for CUPS.
4 * Copyright © 2007-2019 by Apple Inc.
5 * Copyright © 2001-2007 by Easy Software Products.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more
12 * Include necessary headers...
15 #include <cups/cups.h>
17 #include <cups/string-private.h>
18 #include <cups/language-private.h>
19 #include <cups/raster.h>
26 * This driver filter currently supports Dymo, Intellitech, and Zebra
29 * The Dymo portion of the driver has been tested with the 300, 330,
30 * and 330 Turbo label printers; it may also work with other models.
31 * The Dymo printers support printing at 136, 203, and 300 DPI.
33 * The Intellitech portion of the driver has been tested with the
34 * Intellibar 408, 412, and 808 and supports their PCL variant.
36 * The Zebra portion of the driver has been tested with the LP-2844,
37 * LP-2844Z, QL-320, and QL-420 label printers; it may also work with
38 * other models. The driver supports EPL line mode, EPL page mode,
39 * ZPL, and CPCL as defined in Zebra's online developer documentation.
43 * Model number constants...
46 #define DYMO_3x0 0 /* Dymo Labelwriter 300/330/330 Turbo */
48 #define ZEBRA_EPL_LINE 0x10 /* Zebra EPL line mode printers */
49 #define ZEBRA_EPL_PAGE 0x11 /* Zebra EPL page mode printers */
50 #define ZEBRA_ZPL 0x12 /* Zebra ZPL-based printers */
51 #define ZEBRA_CPCL 0x13 /* Zebra CPCL-based printers */
53 #define INTELLITECH_PCL 0x20 /* Intellitech PCL-based printers */
60 unsigned char *Buffer
; /* Output buffer */
61 unsigned char *CompBuffer
; /* Compression buffer */
62 unsigned char *LastBuffer
; /* Last buffer */
63 unsigned Feed
; /* Number of lines to skip */
64 int LastSet
; /* Number of repeat characters */
65 int ModelNumber
, /* cupsModelNumber attribute */
66 Page
, /* Current page */
67 Canceled
; /* Non-zero if job is canceled */
74 void Setup(ppd_file_t
*ppd
);
75 void StartPage(ppd_file_t
*ppd
, cups_page_header2_t
*header
);
76 void EndPage(ppd_file_t
*ppd
, cups_page_header2_t
*header
);
77 void CancelJob(int sig
);
78 void OutputLine(ppd_file_t
*ppd
, cups_page_header2_t
*header
, unsigned y
);
79 void PCLCompress(unsigned char *line
, unsigned length
);
80 void ZPLCompress(unsigned char repeat_char
, unsigned repeat_count
);
84 * 'Setup()' - Prepare the printer for printing.
88 Setup(ppd_file_t
*ppd
) /* I - PPD file */
90 int i
; /* Looping var */
94 * Get the model number from the PPD file...
98 ModelNumber
= ppd
->model_number
;
101 * Initialize based on the model number...
108 * Clear any remaining data...
111 for (i
= 0; i
< 100; i
++)
115 * Reset the printer...
118 fputs("\033@", stdout
);
121 case ZEBRA_EPL_LINE
:
124 case ZEBRA_EPL_PAGE
:
133 case INTELLITECH_PCL
:
135 * Send a PCL reset sequence.
146 * 'StartPage()' - Start a page of graphics.
150 StartPage(ppd_file_t
*ppd
, /* I - PPD file */
151 cups_page_header2_t
*header
) /* I - Page header */
153 ppd_choice_t
*choice
; /* Marked choice */
154 unsigned length
; /* Actual label length */
158 * Show page device dictionary...
161 fprintf(stderr
, "DEBUG: StartPage...\n");
162 fprintf(stderr
, "DEBUG: Duplex = %d\n", header
->Duplex
);
163 fprintf(stderr
, "DEBUG: HWResolution = [ %d %d ]\n", header
->HWResolution
[0], header
->HWResolution
[1]);
164 fprintf(stderr
, "DEBUG: ImagingBoundingBox = [ %d %d %d %d ]\n", header
->ImagingBoundingBox
[0], header
->ImagingBoundingBox
[1], header
->ImagingBoundingBox
[2], header
->ImagingBoundingBox
[3]);
165 fprintf(stderr
, "DEBUG: Margins = [ %d %d ]\n", header
->Margins
[0], header
->Margins
[1]);
166 fprintf(stderr
, "DEBUG: ManualFeed = %d\n", header
->ManualFeed
);
167 fprintf(stderr
, "DEBUG: MediaPosition = %d\n", header
->MediaPosition
);
168 fprintf(stderr
, "DEBUG: NumCopies = %d\n", header
->NumCopies
);
169 fprintf(stderr
, "DEBUG: Orientation = %d\n", header
->Orientation
);
170 fprintf(stderr
, "DEBUG: PageSize = [ %d %d ]\n", header
->PageSize
[0], header
->PageSize
[1]);
171 fprintf(stderr
, "DEBUG: cupsWidth = %d\n", header
->cupsWidth
);
172 fprintf(stderr
, "DEBUG: cupsHeight = %d\n", header
->cupsHeight
);
173 fprintf(stderr
, "DEBUG: cupsMediaType = %d\n", header
->cupsMediaType
);
174 fprintf(stderr
, "DEBUG: cupsBitsPerColor = %d\n", header
->cupsBitsPerColor
);
175 fprintf(stderr
, "DEBUG: cupsBitsPerPixel = %d\n", header
->cupsBitsPerPixel
);
176 fprintf(stderr
, "DEBUG: cupsBytesPerLine = %d\n", header
->cupsBytesPerLine
);
177 fprintf(stderr
, "DEBUG: cupsColorOrder = %d\n", header
->cupsColorOrder
);
178 fprintf(stderr
, "DEBUG: cupsColorSpace = %d\n", header
->cupsColorSpace
);
179 fprintf(stderr
, "DEBUG: cupsCompression = %d\n", header
->cupsCompression
);
185 * Setup printer/job attributes...
188 length
= header
->PageSize
[1] * header
->HWResolution
[1] / 72;
190 printf("\033L%c%c", length
>> 8, length
);
191 printf("\033D%c", header
->cupsBytesPerLine
);
193 printf("\033%c", header
->cupsCompression
+ 'c'); /* Darkness */
196 case ZEBRA_EPL_LINE
:
201 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
202 strcmp(choice
->choice
, "Default"))
203 printf("\033S%.0f", atof(choice
->choice
) * 2.0 - 2.0);
209 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
210 printf("\033D%d", 7 * header
->cupsCompression
/ 100);
213 * Set left margin to 0...
216 fputs("\033M01", stdout
);
219 * Start buffered output...
222 fputs("\033B", stdout
);
225 case ZEBRA_EPL_PAGE
:
227 * Start a new label...
234 * Set hardware options...
237 if (!strcmp(header
->MediaType
, "Direct"))
244 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
245 strcmp(choice
->choice
, "Default"))
247 double val
= atof(choice
->choice
);
250 printf("S%.0f\n", val
);
252 printf("S%.0f\n", val
* 2.0 - 2.0);
259 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
260 printf("D%u\n", 15 * header
->cupsCompression
/ 100);
266 printf("q%u\n", (header
->cupsWidth
+ 7) & ~7U);
274 if (header
->cupsCompression
> 0 && header
->cupsCompression
<= 100)
275 printf("~SD%02u\n", 30 * header
->cupsCompression
/ 100);
278 * Start bitmap graphics...
281 printf("~DGR:CUPS.GRF,%u,%u,\n",
282 header
->cupsHeight
* header
->cupsBytesPerLine
,
283 header
->cupsBytesPerLine
);
286 * Allocate compression buffers...
289 CompBuffer
= malloc(2 * header
->cupsBytesPerLine
+ 1);
290 LastBuffer
= malloc(header
->cupsBytesPerLine
);
299 printf("! 0 %u %u %u %u\r\n", header
->HWResolution
[0],
300 header
->HWResolution
[1], header
->cupsHeight
,
302 printf("PAGE-WIDTH %u\r\n", header
->cupsWidth
);
303 printf("PAGE-HEIGHT %u\r\n", header
->cupsHeight
);
306 case INTELLITECH_PCL
:
308 * Set the media size...
311 printf("\033&l6D\033&k12H"); /* Set 6 LPI, 10 CPI */
312 printf("\033&l0O"); /* Set portrait orientation */
314 switch (header
->PageSize
[1])
316 case 540 : /* Monarch Envelope */
317 printf("\033&l80A"); /* Set page size */
320 case 624 : /* DL Envelope */
321 printf("\033&l90A"); /* Set page size */
324 case 649 : /* C5 Envelope */
325 printf("\033&l91A"); /* Set page size */
328 case 684 : /* COM-10 Envelope */
329 printf("\033&l81A"); /* Set page size */
332 case 756 : /* Executive */
333 printf("\033&l1A"); /* Set page size */
336 case 792 : /* Letter */
337 printf("\033&l2A"); /* Set page size */
341 printf("\033&l26A"); /* Set page size */
344 case 1008 : /* Legal */
345 printf("\033&l3A"); /* Set page size */
348 default : /* Custom size */
349 printf("\033!f%uZ", header
->PageSize
[1] * 300 / 72);
353 printf("\033&l%uP", /* Set page length */
354 header
->PageSize
[1] / 12);
355 printf("\033&l0E"); /* Set top margin to 0 */
356 if (header
->NumCopies
)
357 printf("\033&l%uX", header
->NumCopies
);
358 /* Set number copies */
359 printf("\033&l0L"); /* Turn off perforation skip */
367 if (header
->cupsRowFeed
) /* inPrintRate */
368 printf("\033!p%uS", header
->cupsRowFeed
);
370 if (header
->cupsCompression
!= ~0U)
372 printf("\033&d%dA", 30 * header
->cupsCompression
/ 100 - 15);
374 if ((choice
= ppdFindMarkedChoice(ppd
, "inPrintMode")) != NULL
)
376 if (!strcmp(choice
->choice
, "Standard"))
377 fputs("\033!p0M", stdout
);
378 else if (!strcmp(choice
->choice
, "Tear"))
380 fputs("\033!p1M", stdout
);
382 if (header
->cupsRowCount
) /* inTearInterval */
383 printf("\033!n%uT", header
->cupsRowCount
);
387 fputs("\033!p2M", stdout
);
389 if (header
->cupsRowStep
) /* inCutInterval */
390 printf("\033!n%uC", header
->cupsRowStep
);
399 printf("\033*t%uR", header
->HWResolution
[0]);
402 printf("\033*r%uS", header
->cupsWidth
);
404 printf("\033*r%uT", header
->cupsHeight
);
407 printf("\033&a0H"); /* Set horizontal position */
408 printf("\033&a0V"); /* Set vertical position */
409 printf("\033*r1A"); /* Start graphics */
410 printf("\033*b3M"); /* Set compression */
413 * Allocate compression buffers...
416 CompBuffer
= malloc(2 * header
->cupsBytesPerLine
+ 1);
417 LastBuffer
= malloc(header
->cupsBytesPerLine
);
423 * Allocate memory for a line of graphics...
426 Buffer
= malloc(header
->cupsBytesPerLine
);
432 * 'EndPage()' - Finish a page of graphics.
436 EndPage(ppd_file_t
*ppd
, /* I - PPD file */
437 cups_page_header2_t
*header
) /* I - Page header */
439 int val
; /* Option value */
440 ppd_choice_t
*choice
; /* Marked choice */
447 * Eject the current page...
450 fputs("\033E", stdout
);
453 case ZEBRA_EPL_LINE
:
455 * End buffered output, eject the label...
458 fputs("\033E\014", stdout
);
461 case ZEBRA_EPL_PAGE
:
469 * Cut the label as needed...
472 if (header
->CutMedia
)
480 * Cancel bitmap download...
494 * Rotate 180 degrees so that the top of the label/page is at the
504 printf("^PW%u\n", header
->cupsWidth
);
510 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
511 strcmp(choice
->choice
, "Default"))
513 val
= atoi(choice
->choice
);
514 printf("^PR%d,%d,%d\n", val
, val
, val
);
518 * Put label home in default position (0,0)...
524 * Set media tracking...
527 if (ppdIsMarked(ppd
, "zeMediaTracking", "Continuous"))
530 * Add label length command for continuous...
533 printf("^LL%d\n", header
->cupsHeight
);
536 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Web"))
538 else if (ppdIsMarked(ppd
, "zeMediaTracking", "Mark"))
545 if (header
->cupsRowStep
!= 200)
546 printf("^LT%d\n", header
->cupsRowStep
);
552 if (!strcmp(header
->MediaType
, "Thermal"))
554 else if (!strcmp(header
->MediaType
, "Direct"))
561 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintMode")) != NULL
&&
562 strcmp(choice
->choice
, "Saved"))
566 if (!strcmp(choice
->choice
, "Tear"))
568 else if (!strcmp(choice
->choice
, "Peel"))
570 else if (!strcmp(choice
->choice
, "Rewind"))
572 else if (!strcmp(choice
->choice
, "Applicator"))
579 * Set tear-off adjust position...
582 if (header
->AdvanceDistance
!= 1000)
584 if ((int)header
->AdvanceDistance
< 0)
585 printf("~TA%04d\n", (int)header
->AdvanceDistance
);
587 printf("~TA%03d\n", (int)header
->AdvanceDistance
);
591 * Allow for reprinting after an error...
594 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
596 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
600 * Print multiple copies
603 if (header
->NumCopies
> 1)
604 printf("^PQ%d, 0, 0, N\n", header
->NumCopies
);
607 * Display the label image...
610 puts("^FO0,0^XGR:CUPS.GRF,1,1^FS");
613 * End the label and eject...
619 * Delete the label image...
623 puts("^IDR:CUPS.GRF^FS");
627 * Cut the label as needed...
630 if (header
->CutMedia
)
636 * Set tear-off adjust position...
639 if (header
->AdvanceDistance
!= 1000)
640 printf("PRESENT-AT %d 1\r\n", (int)header
->AdvanceDistance
);
643 * Allow for reprinting after an error...
646 if (ppdIsMarked(ppd
, "zeErrorReprint", "Always"))
647 puts("ON-OUT-OF-PAPER WAIT\r");
648 else if (ppdIsMarked(ppd
, "zeErrorReprint", "Never"))
649 puts("ON-OUT-OF-PAPER PURGE\r");
655 if (header
->CutMedia
)
662 if (header
->cupsCompression
> 0)
663 printf("TONE %u\r\n", 2 * header
->cupsCompression
);
669 if ((choice
= ppdFindMarkedChoice(ppd
, "zePrintRate")) != NULL
&&
670 strcmp(choice
->choice
, "Default"))
672 val
= atoi(choice
->choice
);
673 printf("SPEED %d\r\n", val
);
680 if ((choice
= ppdFindMarkedChoice(ppd
, "zeMediaTracking")) == NULL
||
681 strcmp(choice
->choice
, "Continuous"))
687 case INTELLITECH_PCL
:
688 printf("\033*rB"); /* End GFX */
689 printf("\014"); /* Eject current page */
716 * 'CancelJob()' - Cancel the current job...
720 CancelJob(int sig
) /* I - Signal */
723 * Tell the main loop to stop...
733 * 'OutputLine()' - Output a line of graphics...
737 OutputLine(ppd_file_t
*ppd
, /* I - PPD file */
738 cups_page_header2_t
*header
, /* I - Page header */
739 unsigned y
) /* I - Line number */
741 unsigned i
; /* Looping var */
742 unsigned char *ptr
; /* Pointer into buffer */
743 unsigned char *compptr
; /* Pointer into compression buffer */
744 unsigned char repeat_char
; /* Repeated character */
745 unsigned repeat_count
; /* Number of repeated characters */
746 static const unsigned char *hex
= (const unsigned char *)"0123456789ABCDEF";
756 * See if the line is blank; if not, write it to the printer...
760 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
766 printf("\033f\001%c", 255);
770 printf("\033f\001%c", Feed
);
775 fwrite(Buffer
, header
->cupsBytesPerLine
, 1, stdout
);
782 case ZEBRA_EPL_LINE
:
783 printf("\033g%03d", header
->cupsBytesPerLine
);
784 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
788 case ZEBRA_EPL_PAGE
:
789 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
791 printf("GW0,%d,%d,1\n", y
, header
->cupsBytesPerLine
);
792 for (i
= header
->cupsBytesPerLine
, ptr
= Buffer
; i
> 0; i
--, ptr
++)
801 * Determine if this row is the same as the previous line.
802 * If so, output a ':' and return...
807 if (!memcmp(Buffer
, LastBuffer
, header
->cupsBytesPerLine
))
815 * Convert the line to hex digits...
818 for (ptr
= Buffer
, compptr
= CompBuffer
, i
= header
->cupsBytesPerLine
;
822 *compptr
++ = hex
[*ptr
>> 4];
823 *compptr
++ = hex
[*ptr
& 15];
829 * Run-length compress the graphics...
832 for (compptr
= CompBuffer
+ 1, repeat_char
= CompBuffer
[0], repeat_count
= 1;
835 if (*compptr
== repeat_char
)
839 ZPLCompress(repeat_char
, repeat_count
);
840 repeat_char
= *compptr
;
844 if (repeat_char
== '0')
847 * Handle 0's on the end of the line...
850 if (repeat_count
& 1)
856 if (repeat_count
> 0)
860 ZPLCompress(repeat_char
, repeat_count
);
865 * Save this line for the next round...
868 memcpy(LastBuffer
, Buffer
, header
->cupsBytesPerLine
);
873 if (Buffer
[0] || memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
))
875 printf("CG %u 1 0 %d ", header
->cupsBytesPerLine
, y
);
876 fwrite(Buffer
, 1, header
->cupsBytesPerLine
, stdout
);
882 case INTELLITECH_PCL
:
884 memcmp(Buffer
, Buffer
+ 1, header
->cupsBytesPerLine
- 1))
888 printf("\033*b%dY", Feed
);
893 PCLCompress(Buffer
, header
->cupsBytesPerLine
);
903 * 'PCLCompress()' - Output a PCL (mode 3) compressed line.
907 PCLCompress(unsigned char *line
, /* I - Line to compress */
908 unsigned length
) /* I - Length of line */
910 unsigned char *line_ptr
, /* Current byte pointer */
911 *line_end
, /* End-of-line byte pointer */
912 *comp_ptr
, /* Pointer into compression buffer */
913 *start
, /* Start of compression sequence */
914 *seed
; /* Seed buffer pointer */
915 unsigned count
, /* Count of bytes for output */
916 offset
; /* Offset of bytes for output */
920 * Do delta-row compression...
924 line_end
= line
+ length
;
926 comp_ptr
= CompBuffer
;
929 while (line_ptr
< line_end
)
932 * Find the next non-matching sequence...
940 * The seed buffer is invalid, so do the next 8 bytes, max...
945 if ((count
= (unsigned)(line_end
- line_ptr
)) > 8)
953 * The seed buffer is valid, so compare against it...
956 while (*line_ptr
== *seed
&&
963 if (line_ptr
== line_end
)
966 offset
= (unsigned)(line_ptr
- start
);
969 * Find up to 8 non-matching bytes...
974 while (*line_ptr
!= *seed
&&
975 line_ptr
< line_end
&&
985 * Place mode 3 compression data in the buffer; see HP manuals
992 * Output multi-byte offset...
995 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | 31);
998 while (offset
>= 255)
1004 *comp_ptr
++ = (unsigned char)offset
;
1009 * Output single-byte offset...
1012 *comp_ptr
++ = (unsigned char)(((count
- 1) << 5) | offset
);
1015 memcpy(comp_ptr
, start
, count
);
1020 * Set the length of the data and write it...
1023 printf("\033*b%dW", (int)(comp_ptr
- CompBuffer
));
1024 fwrite(CompBuffer
, (size_t)(comp_ptr
- CompBuffer
), 1, stdout
);
1027 * Save this line as a "seed" buffer for the next...
1030 memcpy(LastBuffer
, line
, length
);
1036 * 'ZPLCompress()' - Output a run-length compression sequence.
1040 ZPLCompress(unsigned char repeat_char
, /* I - Character to repeat */
1041 unsigned repeat_count
) /* I - Number of repeated characters */
1043 if (repeat_count
> 1)
1046 * Print as many z's as possible - they are the largest denomination
1047 * representing 400 characters (zC stands for 400 adjacent C's)
1050 while (repeat_count
>= 400)
1053 repeat_count
-= 400;
1057 * Then print 'g' through 'y' as multiples of 20 characters...
1060 if (repeat_count
>= 20)
1062 putchar((int)('f' + repeat_count
/ 20));
1067 * Finally, print 'G' through 'Y' as 1 through 19 characters...
1070 if (repeat_count
> 0)
1071 putchar((int)('F' + repeat_count
));
1075 * Then the character to be repeated...
1078 putchar((int)repeat_char
);
1083 * 'main()' - Main entry and processing of driver.
1086 int /* O - Exit status */
1087 main(int argc
, /* I - Number of command-line arguments */
1088 char *argv
[]) /* I - Command-line arguments */
1090 int fd
; /* File descriptor */
1091 cups_raster_t
*ras
; /* Raster stream for printing */
1092 cups_page_header2_t header
; /* Page header from file */
1093 unsigned y
; /* Current line */
1094 ppd_file_t
*ppd
; /* PPD file */
1095 int num_options
; /* Number of options */
1096 cups_option_t
*options
; /* Options */
1097 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
1098 struct sigaction action
; /* Actions for POSIX signals */
1099 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
1103 * Make sure status messages are not buffered...
1106 setbuf(stderr
, NULL
);
1109 * Check command-line...
1112 if (argc
< 6 || argc
> 7)
1115 * We don't have the correct number of arguments; write an error message
1119 _cupsLangPrintFilter(stderr
, "ERROR",
1120 _("%s job-id user title copies options [file]"),
1126 * Open the page stream...
1131 if ((fd
= open(argv
[6], O_RDONLY
)) == -1)
1133 _cupsLangPrintError("ERROR", _("Unable to open raster file"));
1141 ras
= cupsRasterOpen(fd
, CUPS_RASTER_READ
);
1144 * Register a signal handler to eject the current page if the
1150 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
1151 sigset(SIGTERM
, CancelJob
);
1152 #elif defined(HAVE_SIGACTION)
1153 memset(&action
, 0, sizeof(action
));
1155 sigemptyset(&action
.sa_mask
);
1156 action
.sa_handler
= CancelJob
;
1157 sigaction(SIGTERM
, &action
, NULL
);
1159 signal(SIGTERM
, CancelJob
);
1160 #endif /* HAVE_SIGSET */
1163 * Open the PPD file and apply options...
1166 num_options
= cupsParseOptions(argv
[5], 0, &options
);
1168 ppd
= ppdOpenFile(getenv("PPD"));
1171 ppd_status_t status
; /* PPD error */
1172 int linenum
; /* Line number */
1174 _cupsLangPrintFilter(stderr
, "ERROR",
1175 _("The PPD file could not be opened."));
1177 status
= ppdLastError(&linenum
);
1179 fprintf(stderr
, "DEBUG: %s on line %d.\n", ppdErrorString(status
), linenum
);
1184 ppdMarkDefaults(ppd
);
1185 cupsMarkOptions(ppd
, num_options
, options
);
1188 * Initialize the print device...
1194 * Process pages as needed...
1199 while (cupsRasterReadHeader2(ras
, &header
))
1202 * Write a status message with the page number and number of copies.
1210 fprintf(stderr
, "PAGE: %d 1\n", Page
);
1211 _cupsLangPrintFilter(stderr
, "INFO", _("Starting page %d."), Page
);
1217 StartPage(ppd
, &header
);
1220 * Loop for each line on the page...
1223 for (y
= 0; y
< header
.cupsHeight
&& !Canceled
; y
++)
1226 * Let the user know how far we have progressed...
1234 _cupsLangPrintFilter(stderr
, "INFO",
1235 _("Printing page %d, %u%% complete."),
1236 Page
, 100 * y
/ header
.cupsHeight
);
1237 fprintf(stderr
, "ATTR: job-media-progress=%u\n",
1238 100 * y
/ header
.cupsHeight
);
1242 * Read a line of graphics...
1245 if (cupsRasterReadPixels(ras
, Buffer
, header
.cupsBytesPerLine
) < 1)
1249 * Write it to the printer...
1252 OutputLine(ppd
, &header
, y
);
1259 _cupsLangPrintFilter(stderr
, "INFO", _("Finished page %d."), Page
);
1261 EndPage(ppd
, &header
);
1268 * Close the raster stream...
1271 cupsRasterClose(ras
);
1276 * Close the PPD file and free the options...
1280 cupsFreeOptions(num_options
, options
);
1283 * If no pages were printed, send an error message...
1288 _cupsLangPrintFilter(stderr
, "ERROR", _("No pages were found."));