]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/rastertolabel.c
Load cups into easysw/current.
[thirdparty/cups.git] / filter / rastertolabel.c
index a3e79d04e2b7c554ac9e3e14a1da46d4318e239c..d883e902fad060c57c8f0b2a297abd091bc5d142 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id$"
+ * "$Id: rastertolabel.c 6649 2007-07-11 21:46:42Z mike $"
  *
  *   Label printer filter for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2001-2006 by Easy Software Products.
+ *   Copyright 2007 by Apple Inc.
+ *   Copyright 2001-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
- *   property of Easy Software Products and are protected by Federal
- *   copyright law.  Distribution and use rights are outlined in the file
- *   "LICENSE.txt" which should have been included with this file.  If this
- *   file is missing or damaged please contact Easy Software Products
- *   at:
- *
- *       Attn: CUPS Licensing Information
- *       Easy Software Products
- *       44141 Airport View Drive, Suite 204
- *       Hollywood, Maryland 20636 USA
- *
- *       Voice: (301) 373-9600
- *       EMail: cups-info@cups.org
- *         WWW: http://www.cups.org
+ *   property of Apple Inc. and are protected by Federal copyright
+ *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+ *   which should have been included with this file.  If this file is
+ *   file is missing or damaged, see the license at "http://www.cups.org/".
  *
  *   This file is subject to the Apple OS-Developed Software exception.
  *
@@ -41,6 +32,7 @@
 
 #include <cups/cups.h>
 #include <cups/string.h>
+#include <cups/i18n.h>
 #include "raster.h"
 #include <stdlib.h>
 #include <unistd.h>
@@ -336,7 +328,7 @@ StartPage(ppd_file_t         *ppd,  /* I - PPD file */
         * Set label size...
        */
 
-        printf("q%d\n", header->cupsWidth);
+        printf("q%d\n", (header->cupsWidth + 7) & ~7);
         break;
 
     case ZEBRA_ZPL :
@@ -372,6 +364,8 @@ StartPage(ppd_file_t         *ppd,  /* I - PPD file */
         printf("! 0 %u %u %u %u\r\n", header->HWResolution[0],
               header->HWResolution[1], header->cupsHeight,
               header->NumCopies);
+       printf("PAGE-WIDTH %d\r\n", header->cupsWidth);
+       printf("PAGE-HEIGHT %d\r\n", header->cupsWidth);
         break;
 
     case INTELLITECH_PCL :
@@ -441,13 +435,25 @@ StartPage(ppd_file_t         *ppd,        /* I - PPD file */
                                        /* inPrintDensity */
            printf("\033&d%dA", 30 * header->cupsCompression / 100 - 15);
 
-          if (header->cupsRowCount != ~0)
-                                       /* inTearInterval */
-           printf("\033!n%dT", header->cupsRowCount);
+         if ((choice = ppdFindMarkedChoice(ppd, "inPrintMode")) != NULL)
+         {
+           if (!strcmp(choice->choice, "Standard"))
+             fputs("\033!p0M", stdout);
+           else if (!strcmp(choice->choice, "Tear"))
+           {
+             fputs("\033!p1M", stdout);
+
+              if (header->cupsRowCount)        /* inTearInterval */
+               printf("\033!n%dT", header->cupsRowCount);
+            }
+           else
+           {
+             fputs("\033!p2M", stdout);
 
-          if (header->cupsRowStep != ~0)
-                                       /* inCutInterval */
-           printf("\033!n%dC", header->cupsRowStep);
+              if (header->cupsRowStep) /* inCutInterval */
+               printf("\033!n%dC", header->cupsRowStep);
+            }
+         }
         }
 
        /*
@@ -710,7 +716,10 @@ EndPage(ppd_file_t *ppd,           /* I - PPD file */
         * Print the label...
        */
 
-        puts("FORM\r");
+       if ((choice = ppdFindMarkedChoice(ppd, "zeMediaTracking")) == NULL ||
+           strcmp(choice->choice, "Continuous"))
+          puts("FORM\r");
+
        puts("PRINT\r");
        break;
 
@@ -872,7 +881,7 @@ OutputLine(ppd_file_t         *ppd, /* I - PPD file */
         * Run-length compress the graphics...
        */
 
-       for (compptr = CompBuffer, repeat_char = CompBuffer[0], repeat_count = 1;
+       for (compptr = CompBuffer + 1, repeat_char = CompBuffer[0], repeat_count = 1;
             *compptr;
             compptr ++)
          if (*compptr == repeat_char)
@@ -891,13 +900,19 @@ OutputLine(ppd_file_t         *ppd,       /* I - PPD file */
          */
 
          if (repeat_count & 1)
+         {
+           repeat_count --;
            putchar('0');
+         }
 
-         putchar(',');
+          if (repeat_count > 0)
+           putchar(',');
        }
        else
          ZPLCompress(repeat_char, repeat_count);
 
+       fflush(stdout);
+
        /*
         * Save this line for the next round...
        */
@@ -1153,7 +1168,8 @@ main(int  argc,                           /* I - Number of command-line arguments */
     * and return.
     */
 
-    fputs("ERROR: rastertolabel job-id user title copies options [file]\n", stderr);
+    fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+            argv[0]);
     return (1);
   }
 
@@ -1227,7 +1243,7 @@ main(int  argc,                           /* I - Number of command-line arguments */
       */
 
       if ((y & 15) == 0)
-        fprintf(stderr, "INFO: Printing page %d, %d%% complete...\n", Page,
+        fprintf(stderr, _("INFO: Printing page %d, %d%% complete...\n"), Page,
                100 * y / header.cupsHeight);
 
      /*
@@ -1274,14 +1290,14 @@ main(int  argc,                         /* I - Number of command-line arguments */
   */
 
   if (Page == 0)
-    fputs("ERROR: No pages found!\n", stderr);
+    fputs(_("ERROR: No pages found!\n"), stderr);
   else
-    fputs("INFO: Ready to print.\n", stderr);
+    fputs(_("INFO: Ready to print.\n"), stderr);
 
   return (Page == 0);
 }
 
 
 /*
- * End of "$Id$".
+ * End of "$Id: rastertolabel.c 6649 2007-07-11 21:46:42Z mike $".
  */