i'd like to know how to center barcode code 128. on the picture you should see that it is right now left justified.
my zpl:
^XA
^LH10,10
^FO0,0^XGE:SWESE001.GRF^FS
^FO440,0^XGE:SWESE000.GRF^FS
^FO0,70^FB550,50,0,C,0^AQN,25,30^FDSpraynozzle 50mm^FS
^FO0,130^BY2^BCN,30,Y,Y,N,N^FDS/N:941001-0114-0001^FS
^FO180,170^AQN,23,20^FDwww.swepro.com^FS
^XZ
Under the dashboard, tap Product Setup. Find your item by using the search bar or tapping its corresponding Category and Subcategory. Then tap OK, then choose Print Labels. Labels should print directly from the Zebra Printer.
There is not a separate command to draw a simple horizontal or vertical line, but the ^GB command can be used for this purpose by drawing a rectangle with height = 1 (horizontal line) or width = 1 (vertical line).
After downloading, open Zdesigner software and click on the Open Communication with Printer button. Click the Open File icon and select a ZPL label file from your computer. Click the Send to Printer button.
I'm posting my solution in case someone is looking for it. As E_S mentions, in order to center a barcode in a label you have to calculate it by code following these steps:
(^BY2)
(eg: 8 dots / mm)
. so if you have a 80 mm
wide label, 80 * 8 = 640 dots
(">:", ">5", etc.)
count as one character, and that characters in mode C
are stored in pairs. For more information on mode C
, refer to http://en.wikipedia.org/wiki/Code_128
>:S/N:941001-0114-0001
you have to count [start code B] + [20 characters] + [check digit] = 22 >:S/N:>5941001>6->50114>6->50001
you have to count [start code B] + [4 characters for 'S/N:'] + [mode C invocation] + [3 characters for '941001'] + [mode B invocation] + [1 characters for '-'] + [mode C invocation] + [2 characters for '0114'] + [mode B invocation] + [1 characters for '-'] + [mode C invocation] + [2 characters for '0001'] + [check digit] = 20
stop code
that has 2 extra units (that is a total of 13)((chars counted [22 or 20] * 11) + (stop char * 13)) * narrow bar width = 510 dots or 466 dots
round((label width - barcode width) / 2)
and use that to position the barcode with ^FT
That's it! Hope it helps someone!
Another solution to this problem, not as elegant as by Nicolas Garfinkiel, but much much simpler, is the following one.
Fundamentally the problem with Code 128 is that it is variable width. But is real life situation, we anyway use it as fixed width. This needs explanation. We position the code somewhere, and we expect it be no wider than some, otherwise it wouldn't fit, and we must reserve (keep empty) the space it is allowed to fill. Thus, even though it's variable width, we always need to allocate for it fixed area on a label.
So the solution to the centering problem would be to make Code 128 fixed-length.
If this is subset C (pairs of digits), then you need:
For example, if your code was 94100101140001, then you can add it with 10^16, and get this:
10000000000000000
94100101140001
=================
10094100101140001
Thus the code becomes fixed-width, and can be hard-centered.
If your code is not subset C, and contains text, then (in pseudocode) you do:
my_code = "S/N:941001-0114-0001"
const_max_code_length = 24 (for example)
if my-code.length > const_max_code_length then error
padding_char = "="
result = ""
for (0..(const_max_code_length - my_code.length)) do
result += padding_char
end_for
result += my_code
In case of your code, it will produce:
====S/N:941001-0114-0001
Then, no matter what text you put into it, it'll always be fixed length, and so will be positioned consistently.
I used it myself, before found this post. It's not OK, it's a hack, and what Nicolas Garfinkiel suggested is more right. The most appropriate solution would be, though, if ZPL itself would support code centering, and unfortunately it doesn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With