[barcode] barcode on PCL printer

Andrea Scopece a.scopece@vizzavi.it
Sat, 19 Oct 2002 03:06:51 -0000


Well, I finally double-checked PCL output versus PS output:

PS output use Points as unit of measure, with a precision of  1/100,
therefore equivalent to 1/7200 of Inch.

PCL output was using decipoints, with unitary precision, equivalent to 1/720
of Inch.

I changed pcl.c code, for use of decipoints with a precision of 1/10,
therefore
equivalent to PS output, and checked it, it look bar width were corrected,
but
x coordinates positions were a little different from PS output.
(probably when I writed pcl.c, and I looked manuals, I see the range value
(0-32676),
and don't see a note that command allow for 2 decimal places)

Finally I realized that when pcl.c was corrected for difference about
drawing from PS and PCL,
(PS line drawing need center coordinate of the bar, PCL rectangular are fill
needs left x coordinate of the bar), that patch don't take in account for
SHRINK_AMOUNT.

Now, PCL output value look like PS output value.

Please, try the following patch:

-----------------------snip------------------------
diff -ur barcode-0.98/pcl.c work2/pcl.c
--- barcode-0.98/pcl.c Tue Nov 13 13:38:19 2001
+++ work2/pcl.c Sat Oct 19 02:41:08 2002
@@ -131,7 +131,7 @@
  if (isdigit (*ptr))   j = *ptr-'0';
  else                  j = *ptr-'a'+1;
  if (i%2) { /* bar */
-     x0 = bc->xoff + xpos;
+     x0 = bc->xoff + xpos + SHRINK_AMOUNT/2.0;
             y0 = bc->yoff + bc->margin;
             yr = bc->height;
             if (!(bc->flags & BARCODE_NO_ASCII)) { /* leave space for text
*/
@@ -145,10 +145,10 @@
   }
      }

-     fprintf(f,"%c&a%.0fH", 27, x0 * 10.0);
-     fprintf(f,"%c&a%.0fV", 27, y0 * 10.0);
-     fprintf(f,"%c*c%.0fH", 27, ((j*scalef)-SHRINK_AMOUNT) * 10.0);
-     fprintf(f,"%c*c%.0fV", 27, yr * 10.0);
+     fprintf(f,"%c&a%.1fH", 27, x0 * 10.0);
+     fprintf(f,"%c&a%.1fV", 27, y0 * 10.0);
+     fprintf(f,"%c*c%.1fH", 27, ((j*scalef)-SHRINK_AMOUNT) * 10.0);
+     fprintf(f,"%c*c%.1fV", 27, yr * 10.0);
      fprintf(f,"%c*c0P\n", 27);
  }
  xpos += j * scalef;

-----------------------snip------------------------

Best Regards

Andrea Scopece