'Print UPC-A without elongated guard bars using ZPL

I'm trying to print a UPC-A barcode from a Zebra printer using ZPL. It always comes out with elongated guard bars like this: enter image description here

I need it to print like a Code 128 style where all the lines are the same length but encoded UPC-A style: enter image description here

Here is a basic ZPL: ^XA ^BY3^BUN,70,N,N,N,A ^FD42222200439^FS ^XZ

Any ideas? Thanks.



Solution 1:[1]

The only way I have seen to get rid of the descents on the guard bars is to draw over them with a white rectangle. This is straightforward to do with UPC-A since it is a fixed width barcode (95 modules wide) and the descenders are 5 modules in height. Since you are using ^BY3, we need to multiply those numbers by 3, giving a width of 285px and a height of 15px for the descenders.

The example below uses ^FT to position the barcode by its lower left corner. Note that guard bars extend below that position. Then we draw a white rectangle on top of the guard bar descents at the same origin, this time using ^FO:

^XA 
^FT50,200^BY3^BUN,70,N,N,N^FD42222200439^FS
^FO50,200^GB285,15,15,W^FS
^XZ

Here is how it looks using the labelary emulator.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1