Skip to main content

ZPL how-to

Print copies of a ZPL label with ^PQ

One command inside the label sets how many to print: ^PQ3 before ^XZ prints three copies of the same label, without sending it three times.

Copies: ^PQ

zpl
^XA
^CF0,50
^FO40,40^FDShelf 3^FS
^BY2^FO40,110^BCN,100,Y,N,N^FDS03-12^FS
^PQ3
^XZ
  • In Labelary this printed 3 labels, each scanning as S03-12.
  • ^PQ can go anywhere between ^XA and ^XZ. Moved to straight after ^XA, it still printed 3.
  • Zebra's reference allows from 1 to 99,999,999 copies.

Why ^PQ prints only one copy

The usual cause is ^PQ added to the end of the ZPL, after ^XZ:

zpl
^XA
^CF0,50
^FO40,40^FDShelf 3^FS
^BY2^FO40,110^BCN,100,Y,N,N^FDS03-12^FS
^XZ
^PQ3

In Labelary this printed 1 label. ^PQ belongs to the label it is in, and after ^XZ it is in none. Put it before ^XZ.

Also seen in Labelary:

  • Two ^PQ in one label: the last one counts. ^PQ5 then ^PQ2 printed 2.
  • ^PQ0 printed 1. Zebra's reference starts at 1, so do not rely on 0 to print nothing.
  • Each label's ^PQ is its own. Two labels in one job, each with ^PQ2, printed 4: two of the first, then two of the second. ^PQ does not carry into the next label (Several labels in one ZPL job).

Copies of each serial number

With ^SN, ^PQ's first value is the total number of labels. Its third, which Zebra's reference calls "replicates of each serial number", repeats each number. Print a short run on your printer before relying on it: Labelary and the wording of Zebra's reference do not agree on how many copies a value gives.

zpl
^XA
^CF0,50
^FO40,40^FDShelf 3^FS
^BY2^FO40,110^BCN,100,Y,N,N^SNS03-01,1,Y^FS
^PQ6,0,2
^XZ
  • In Labelary this printed 6 labels: S03-01, S03-01, S03-02, S03-02, S03-03, S03-03. Six in all, so three numbers.
  • In Labelary, 2 printed each number twice, and 1 printed each number once, the same as leaving it out: ^PQ6,0,1 printed S03-01, S03-02, S03-03, S03-04, S03-05, S03-06. Zebra's reference gives 0 as "no replicates" and describes 1 as "one replicate of each serial number", which reads as one extra copy. A printer that follows that wording would print three of each number for ^PQ6,0,2.
  • Several labels in one ZPL job explains ^SN.

Pausing between batches

^PQ has more values for printers with a cutter or an operator, described in Zebra's reference and not checked here, since Labelary does not pause or cut:

  • The second, p, pauses the printer after every p labels. ^PQ50,10 prints 50 in batches of 10. The default, 0, never pauses.
  • The fourth, o, set to Y, prints straight through without pausing, and a cutter still cuts after each batch.
  • The fifth, e, is for RFID printers: whether a cutter cuts after a voided RFID label.

Copies 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 "copies": 3
5 },
6 "data": {
7 "shelf": "Shelf 3",
8 "code": "S03-12"
9 },
10 "templates": [
11 {
12 "type": "Text",
13 "dataPath": "shelf",
14 "coords": [40, 40],
15 "font": "0,50"
16 },
17 {
18 "type": "BarCode",
19 "dataPath": "code",
20 "coords": [40, 110]
21 }
22 ]
23}

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^FDShelf 3^FS
^BY2,2,59^FO40,110^BCN,,N,N,N,A^FDS03-12^FS
^PQ3
^XZ

Set copies in the request's config. zeepler puts ^PQ just before the label's ^XZ, where it counts. In Labelary the response below printed 3 labels.

  • copies takes a whole number from 1 to 99,999,999, Zebra's range. Leave it out for one.
  • Every copy is the same label. For a different serial number on each, send one label per number.

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.