Search code examples
zebra-printerszpl

ZPL Center text vertically


Is there a way in ZPL to center text vertically?

I know I can use ^FO0,0^ASN,50^FB200,3,0,C,0^FD TEXT ^FS. But how can I make that print on the 2nd line if it's short enough?


Solution

  • There isn't a vertical centering feature, but you can fake it, if you know in advance that your string is short enough to fit on the middle line.

    Your ^FB defines a field block that is three lines. So your best option is to determine if your string fits on one line... and if it does, insert a "\&" before your string.

    ^FO0,0^ASN,50^FB200,3,0,C,0^FD\&TEXT^FS