ZPL - how to right justify a bar code?
Asked Answered
P

2

6

I am trying to right justify a bar code I am printing using ZPL from a .Net program. Here is my current code:

^FO10,50^FB500,1,0,R,0^AO,40,40^BY3^BCN,100,Y,N,N^FD1234567^FS^XZ

The Field Block seems to be ignored when working with a bar code, but for text it justifies it correctly. Any ideas?

Prescribe answered 13/9, 2013 at 14:7 Comment(0)
F
11

Newer Zebra firmware supports a third parameter on ^FO and ^FT. If you want to right justify something, specify the right edge as the x parameter, and include a 1 as the third parameter.

^XA
^BY3
^FO85,30^GB500,450,3^FS
^FO100,50^BCN,30,Y,N,N
^FD>;12345678^FS
^FO100,120N^BCN,30,Y,N,N
^FD>;123456^FS
^FO100,190^BCN,30,Y,N,N
^FD>;1234^FS
^FO570,260,1^BCN,30,Y,N,N
^FD>;12345678^FS
^FO570,330,1^BCN,30,Y,N,N
^FD>;123456^FS
^FO570,400,1^BY3^BCN,30,Y,N,N
^FD>;1234^FS
^XZ

Finnigan answered 16/11, 2014 at 6:16 Comment(0)
C
2

We had the same issue at our company. The barcode doesn't respond to the Field Block. Based on your example since you are using ZPL commands directly to generate your barcode (as opposed to an image of a barcode), you could do something similar to how we did. We know roughly how wide the barcode is going to be based on the data we write to it. So we created a method to determine the x-axis location of the barcode based on our also known label widths.

For example: We use the s4M printers and estimate the full label width to be about 780 dots wide. So in order to left/center/right justify, we take the rough barcode (estimated) width and calculate accordingly (left is set to xaxis = 0, center is set to xaxis = ((780 - barcodeWidth) / 2), and right justified would be xaxis = (780 - barcodeWidth). It isn't a perfect solution but is very close at least for our needs. You could certainly be more precise in your algorithm by looking at more barcode setting information like the data square size, columns, rows, etc... depending on your needs.

If you were to come up with a solution of generating an image of a barcode (which is what we are also trying to come up with now) then you should be able to easily get the width of the barcode image using build in .net graphics functionality.

Canard answered 14/10, 2013 at 15:26 Comment(2)
how are you able to calculate a rough estimate of the barcode width?Parthenope
If your data is a fixed length item (for example consistent length ID value/UPC code, etc) then print a sample, determine how much of the width of the badge it is using with a ruler, then calculate (example, print a barcode, if it is 1/5 the width of the badge then it's width is (badgewidthInDots * .2). In our case the data we encode varies by user, so we purposely trim or pad our barcode's data to an exact character count to get a fixed width barcode no matter what (for the exact purpose of controlling size to determine justification and real estate consumed when printed).Canard

© 2022 - 2024 — McMap. All rights reserved.