Skip to main content

ZPL how-to

Rotate text and barcodes in ZPL

ZPL fonts and most barcodes take an orientation letter: N normal, R a quarter turn clockwise, I upside down, B a quarter turn the other way, read from the bottom up. QR codes do not turn.

Rotate text: the letter after the font

zpl
^XA
^FO100,40^A0R,50,50^FDRack 12^FS
^XZ
  • ^A0R,50,50: font 0, turned clockwise, 50 dots tall and wide. The text reads from top to bottom.
  • ^FO is the top-left corner of the turned field. In Labelary the text printed at x 112 to 150, y 43 to 196; unturned, at x 103 to 256, y 39 to 77.
  • B turns it the other way, read from the bottom up, from the same corner:
    zpl
    ^XA
    ^FO100,40^A0B,50,50^FDRack 12^FS
    ^XZ
    It printed at x 99 to 137, y 42 to 195. I printed upside down, at x 102 to 255, y 52 to 90.
  • ^FT gives the start of the baseline instead of the corner. For B that is at the bottom, so the text runs up from y 300, with its baseline at x 100:
    zpl
    ^XA
    ^FT100,300^A0B,50,50^FDRack 12^FS
    ^XZ
    It printed at x 62 to 100, y 143 to 296.

Rotate a barcode

zpl
^XA
^BY2^FO100,40^BCR,80,Y,N,N^FDR12-A^FS
^XZ
  • The letter is ^BC's first value. The bars ran down the label from y 40 to 219, starting at the ^FO x.
  • In Labelary the text line went on the bars' left, outside the ^FO corner, from x 80. Leave room for it.
  • QR codes have no orientation letter. Zebra's ^BQ reference gives normal only, and says ^FW does not turn them.

Every field at once: ^FW

zpl
^XA
^FWR
^FO100,40^A0,50,50^FDRack 12^FS
^FO300,40^BY2^BCN,80,Y,N,N^FDR12-A^FS
^XZ

^FWR sets the orientation for every field after it that does not give its own. The text, ^A0 with no letter, turned. The barcode, ^BCN, stayed as it was, from x 300 to 479.

The whole label

^POI prints the whole label upside down, for labels that come out of the printer the other way round:

zpl
^XA
^POI
^FO100,40^A0N,50,50^FDRack 12^FS
^XZ

In Labelary, which turned the 812 by 406 dot label about its middle, the text moved to x 555 to 708, y 328 to 366, the bottom right, upside down. Zebra's reference says ^POI inverts the x and y positions and that ^LL, ^LS, ^LT and ^PF change the result, so on a printer where a field lands depends on its print width and label length. Print one label to check. There is no command for a quarter turn of the whole label: give each field a new position and its own letter.

^FW and ^PO stay set

Zebra's reference: both are kept until the printer is switched off or gets another one. In Labelary, a second label after a ^FWR label printed its text turned, and one after a ^POI label printed upside down. If anything sends ^FW or ^PO to your printer, start each label with ^FWN,0 and ^PON. The ,0 matters: ^FW's second value is the field justification, and ^FWN alone keeps the one an earlier ^FW set. Several labels in one ZPL job covers other settings that carry over.

Rotation and zeepler

Send this body to POST https://api.zeepler.com/v1/zeeplify with your API key in the x-api-key header. It is a working request, not an illustration: on every change, our tests run this same file through the API's code and compare the result with the ZPL below.

json
1{
2 "config": {
3 "size": "4x2"
4 },
5 "data": {
6 "rack": "Rack 12",
7 "code": "R12-A"
8 },
9 "templates": [
10 {
11 "type": "Text",
12 "dataPath": "rack",
13 "coords": [40, 40],
14 "font": "0,50",
15 "orientation": "R"
16 },
17 {
18 "type": "BarCode",
19 "dataPath": "code",
20 "coords": [120, 40],
21 "orientation": "R"
22 }
23 ]
24}

And the ZPL that comes back, ready to send to the printer:

zpl
^XA^MCY^XZ
    ^XA
    ^SZ2
    ^MMT
    ^MNY
    ^LL406
    ^PW812
    ^LH0,0
^CF0,50^FO40,40^A0R,50^FDRack 12^FS
^BY2,2,59^FO120,40^BCR,,N,N,N,A^FDR12-A^FS
^XZ

Give a Text or BarCode element an orientation: N, R, I or B, as above. zeepler sends a turned Text as ^A with the element's font and the letter, so it needs a font, and sends the letter as the barcode command's first value. This request turns both a quarter clockwise. In Labelary it printed at x 52 to 178, y 40 to 219.

  • coords is the top-left corner of the turned field, as ^FO is above.
  • Turned R or B, a barcode's height runs across the label, so zeepler allows up to the label's width, less any text line, instead of its height.
  • align center and right work only with N.
  • QR codes take no orientation: zeepler refuses one with a 400.

zeepler's labels set neither ^FW nor ^PO unless you ask. A barcode, or a Text turned R, I or B, gives its own letter, so ^FW does not turn it: sent after ^XA^FWR^XZ, this response printed where it did on its own. A Text with orientation N, or none, sends no ^A, though, so it still takes the letter: with the Text's orientation set to N or left out, it printed turned, down to y 196. ^PO and ^FW's justification carry over too: after ^XA^POI^XZ the response printed upside down, at x 633 to 759, y 186 to 365, and after ^XA^FWN,1^XZ at x 2 to 119, y 40 to 219, each field ending at its x instead of starting there.

Set "resetPrinter": true in the request's config and zeepler starts the label with ^FWN,0^PON^PMN^LRN. Sent after ^XA^FWR^POI^XZ or ^XA^FWN,1^XZ, the response with it printed as it did on its own. The ,0 needs Zebra firmware V60.14.x, V50.14.x or later.

If you build the print job yourself, you can send this before zeepler's labels instead. It prints nothing:

zpl
^XA^FWN,0^PON^XZ

After it, the response printed as it did on its own, after either label. ^FWN without the ,0 did not undo ^FWN,1: the response still printed at x 2 to 119, y 40 to 219.

Sending it

  • Call the API from your own server or integration engine, not from a web page. An API key in a browser is a key anyone can copy.
  • A successful call answers 200 with the ZPL as plain text. A request the API cannot turn into a label answers 400 with every problem listed by field, and is not billed.
  • Send the ZPL to a Zebra or other ZPL printer at 203 dpi. At 300 dpi the same label prints at two-thirds of the size.

The API reference has every field and status code.

Before you go live

  • Text does not wrap. A value longer than the space you left runs off the edge of the label, so set maxLength on any field whose length you do not control.
  • Coordinates are in dots from the top-left corner. Print one label, measure it, and adjust: there is no preview.
  • Scan every barcode and QR code on a printed label before relying on it.

Related guides

Help with an integration

Email info@zeepler.com. You will get a reply within 2 business days. The support policy covers response times and version changes.