ZPL As a center barcode (code 128)

I would like to know how to copy the code of the bar code 128 in the image you should see that it is now left justified. Label

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 
+8
source share
5 answers

I publish my decision in case someone is looking for it. As E_S mentions, to center a barcode on a label, you need to calculate it by code by doing the following:

  • Check the width of the narrow strip in your case 2 (^BY2)
  • Find out the total width of your label in the points. To do this, you need to know what resolution your printer (eg: 8 dots/mm) . so if you have a label width of 80 mm , 80 * 8 = 640 dots
  • Count each character in your barcode, including call codes and check digit, as shown below. To obtain information about the call codes cm .: https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-pm-en.pdf (p. 95).
  • Please note that the access codes (">:", ">5", etc.) is considered as one symbol, and symbols in the mode C are stored in pairs. For more information about the mode C , refer to http://en.wikipedia.org/wiki/Code_128
  • If your bar code >:S/N:941001-0114-0001 you need to count [Bed and start code] + [20 characters] + [check digit] = 22
  • If your bar code >:S/N:>5941001>6->50114>6->50001 you have to count the [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 ] + [mode C invocation] + [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 + [ [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 mode C invocation] + [ [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 + [ [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 ] + [ [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
  • Each symbol occupies 11 units, mixing and band gaps except stop code which has 2 additional units (of 13)
  • And here is the good stuff ... The width of the bar code: ((chars counted [22 or 20] * 11) + (stop char * 13)) * narrow bar width = 510 dots or 466 dots
  • Now all we have to do is round((label width - barcode width)/2) ) / ^FT round((label width - barcode width)/2) and used for the positioning of the bar code using ^FT

It! Hope this helps someone!

+15
source

No ZPL commands to align the code. Your program that generates ZPL should automatically calculate the position based on code size and position using coordinates.

+3
source

Another solution to this problem is not as elegant as that of Nicholas Garfinkel, but much more simple, is as follows.

The fundamental problem with the code 128 is that it has a variable width. But in real life, we still use it as a fixed width. This requires an explanation. We place the code somewhere and expect that it will be wider than any, otherwise it will not fit, and we must reserve (left blank) space, which allowed him to fill. Thus, even if it is a variable width, we always need to select for it a fixed area on the label.

Thus, the solution to the problem of centering it would make the code 128 of fixed length.

If this is a subset of C (pairs of digits), you will need:

  1. Get any big enough number in the form of 100000 ... so that the total will be even.
  2. Add your code to it.

For example, if your code 94100101140001, you can add it with 10 ^ 16 and receive the following:

 10000000000000000 94100101140001 ================= 10094100101140001 

Thus, the code becomes a fixed width and can be highly centered.

If your code is not a subset of C, and contains text, (in pseudo-code) 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 " 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 the case of your code, it will produce:

 ====S/N:941001-0114-0001 

Then, no matter what text you insert into it, it will always have a fixed length and will therefore be placed in series.

I've used it myself, before I found this post. This is not good, this is a hack, and what Nicholas Garfinkel suggested is more correct. However, the best solution would be if he ZPL supported centering code, and, unfortunately, no.

0
source

you should use the tray:

  ^FO10,170^AQN,23,20^FDwww.swepro.com^FS 

. Where
, ^ FOX, Y ^ AQN, FS ... ^ X=x-axis location and Y=y-axis location

-2
source

Click on the box next to "" print bar code as a graffiti "in the application" Barcode ".

This worked in my case.

-3
source

All Articles