Skip to main content

ZPL how-to

Several labels in one ZPL job

Every ^XA … ^XZ block is one label, and a job can hold as many as you like. The catch is that settings from one label carry into the next.

Join the labels

Put one label after another and send them together. Two different labels in one job:

zpl
^XA
^CF0,50
^FO40,40^FDBin 117-1^FS
^BY2^FO40,120^BCN,80,N,N^FD117-1^FS
^XZ
^XA
^CF0,50
^FO40,40^FDBin 117-2^FS
^BY2^FO40,120^BCN,80,N,N^FD117-2^FS
^XZ

In Labelary this printed two labels, each with its own text and barcode. There is no separator to add and nothing to put around them: the printer starts a new label at each ^XA.

What carries into the next label

Many settings do not reset between labels: one that a label sets stays in force for the next unless that label sets it again. Here the second label sets no font:

zpl
^XA
^CF0,80
^FO40,40^FDBin 117-1^FS
^XZ
^XA
^FO40,40^FDBin 117-2^FS
^XZ

In Labelary its text printed 60 dots tall, in the first label's ^CF0,80, not in the printer's small default font. The same goes for:

Have every label set what it relies on, as the two labels at the top of this page each set ^CF and ^BY. Then each prints the same on its own, first in the job, or after anything else.

A numbered run: ^SN and ^PQ

When the labels differ only by a number that goes up by one, the printer can count for you. ^SN takes the place of ^FD, and ^PQ sets how many labels to print:

zpl
^XA
^CF0,50
^FO40,40^SNBin 117-1,1,N^FS
^PQ4
^XZ
  • In Labelary this printed four labels, "Bin 117-1" to "Bin 117-4". The printer counts up the last number in the value, here the 1 after the dash.
  • ^SNBin 117-1,1,N: start at Bin 117-1, add 1 for each label, no leading zeros. A negative step counts down.
  • Zebra's reference notes one surprise: if the printer runs out of labels or ribbon in the middle of a run, it prints the interrupted number again once it is reloaded, in case that label did not print in full.
  • The count ends with the label: ^PQ does not carry into the next one. In Labelary, this run followed by a plain label printed five labels, not eight.

Several labels with 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 "bin": "Bin 117-1",
7 "code": "117-1"
8 },
9 "templates": [
10 {
11 "type": "Text",
12 "dataPath": "bin",
13 "coords": [40, 40],
14 "font": "0,50"
15 },
16 {
17 "type": "BarCode",
18 "dataPath": "code",
19 "coords": [40, 120]
20 }
21 ]
22}

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^FDBin 117-1^FS
^BY2,2,59^FO40,120^BCN,,N,N,N,A^FD117-1^FS
^XZ

zeepler makes one label per request. To print several, make one request for each label, join the responses one after another, and send the result to the printer in one go. Each response starts with an ^XA^MCY^XZ block that prints nothing, so joined responses need nothing between them.

  • Every response sets ^LH0,0, ^PW and ^LL itself, and sets ^BY before every barcode and QR code, so none of those carry over from the label before.
  • The font does. A Text element without a font has no ^CF of its own, so it takes the font the previous label left. In Labelary, a zeepler label whose Text had no font printed 7 dots tall on its own and 60 dots tall after a label that used "0,80". Give the first Text element of every label a font, as this request does.
  • So do ^FW, ^PO, ^PM and ^LR: field rotation and justification, whole-label rotation, mirror image and reverse print. zeepler leaves them as they are unless the request's config sets "resetPrinter": true; then each label starts with ^FWN,0^PON^PMN^LRN. In Labelary, this request printed at x 40 to 254, y 40 to 178 on its own, at x 592 to 771, y 151 to 361 after ^XA^FWR^POI^XZ, and at x 556 to 771, y 39 to 178, mirrored, after ^XA^PMY^LRY^XZ. With resetPrinter, sent after all four, it printed as it did on its own.
  • zeepler has no serial numbers: send each number as its own request, as the data of one label.

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.