ZPL How to center text with variable length
Asked Answered
F

2

8

I use Zebra Designer to create my labels. But I have a problem to center my elements.

Indeed when I create a text box with Zebra Designer, it has a fixed length and when I replace the text inside (by a variable Php giving me the price for example) ==> if this text is larger than this that I have defined it does not focus.

So I would like to create a text box the width of the label and where the text would be centered inside, regardless of its length

CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTD^PON^PMN^LH0,0^JMA^PR5,5~SD15^JUS^LRN^CI0^XZ
^XA
^FT256,576^XG014.GRF,1,1^FS
^FT256,576^XG015.GRF,1,1^FS
^BY3,3,52^FT127,484^BCB,,Y,N
^FD>:$customer_key^FS
^FT56,429^A0B,28,28^FH\^FDTEXT_TO_REPLACE^FS
^FT197,401^A0B,28,28^FH\^FDTEXT_TO_REPLACE^FS
^BY3,3,57^FT781,434^BCB,,Y,N
^FO256,23^GB0,559,1^FS
^PQ1,0,1,Y^XZ
^XA^ID000.GRF^FS^XZ
^XA^ID015.GRF^FS^XZ
Frontality answered 23/5, 2018 at 8:15 Comment(0)
B
14

Use the Field Block ^FB Command; Parameter D is the justification, here set to C for center

^FT250,600^A0B,28,28^FB600,1,0,C^FH\^FDTEXT_TO_REPLACE^FS
Bering answered 23/5, 2018 at 23:26 Comment(1)
it seem like TEXT_TO_REPLACE over laps, so some kind of padding needs to be done as well for the with variable lengthIncompetence
C
0

Download the ttf font for your barcode to the printer, using the Zebra printer utilities. Print the barcode in a centered text box using the barcode font.

The following online utility is helpful: http://labelary.com/viewer.html

Zebra article on using external fonts: https://www.zebra.com/us/en/support-downloads/knowledge-articles/ait/downloading-and-using-fonts-on-zebra-zpl-printers.html

Sample below:

^PR
^XA
^CF0,30,30
^FO0,30
    
^A@N,50,70,E:COD000.FNT
    
^FB525,1,0,C,0
^FD *BARCODE_DATA* \&^FS
^XZ
Cunha answered 5/1, 2021 at 19:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.