Rocstar
Rocstar

Reputation: 1487

ZPL How to center text with variable length

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

Upvotes: 8

Views: 30364

Answers (2)

Skye Bowen
Skye Bowen

Reputation: 49

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

Upvotes: 0

EdHayes3
EdHayes3

Reputation: 1953

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

Upvotes: 14

Related Questions