ZPL How to center text with variable length

2019-08-13 08:14发布

问题:

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

回答1:

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