Skip to main content

ZPL how-to

QR code size in ZPL

A QR code in ZPL has no width or height setting. Its size comes from two things: the magnification in ^BQ, and how much data it carries.

In plain ZPL

zpl
^XA
^FO40,40^BQN,2,5^FDQA,https://zeepler.com/r/A1^FS
^XZ
  • ^BQN,2,5: a QR code, normal orientation, model 2 (the current standard, and the one to use), at magnification 5. Magnification runs from 1 to 10 and is the width of one module, the smallest black or white square, in dots.
  • QA, at the start of the field data is not printed. Q is the error correction level (about 25% of the code can be damaged and still scan) and A picks the data mode automatically.

Working out the size

The printed width is the number of modules across the code times the magnification. The number of modules depends on the data: this 24-character link at level Q needs a 29 × 29 module code, so magnification 5 prints it 145 dots wide, about 0.71 inch at 203 dpi.

  • To make the code bigger or smaller, change the magnification.
  • Longer data needs more modules, so the same magnification prints a bigger code. A short link keeps the code small.
  • Leave blank space around the code, four modules wide, so a scanner can find its edges.

The same label 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 "small": "https://zeepler.com/r/A1",
7 "large": "https://zeepler.com/r/A1"
8 },
9 "templates": [
10 {
11 "type": "QRCode",
12 "dataPath": "small",
13 "coords": [40, 60],
14 "magnification": 3
15 },
16 {
17 "type": "QRCode",
18 "dataPath": "large",
19 "coords": [300, 40],
20 "magnification": 8
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
^BY2,2,0^FO40,60^BQN,2,3^FDQA,https://zeepler.com/r/A1^FS
^BY2,2,0^FO300,40^BQN,2,8^FDQA,https://zeepler.com/r/A1^FS
^XZ

magnification is the same 1 to 10, and zeepler adds the QA, for you. The two codes carry the same link at magnification 3 and 8: 87 and 232 dots wide.

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

  • Print and scan the code at the smallest magnification you plan to use, with your own scanners.
  • 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

  • Printing ^, ~ and _ in ZPL: Why a caret or tilde in your data cuts the field short, and how ^FH prints them.
  • Font size in ZPL: Setting text height with ^A and ^CF, converting points to dots, and why ^CF carries over.
  • Send ZPL to a Zebra printer from C#: Send ZPL from .NET to a network printer on port 9100, or to a USB printer through the Windows spooler, without the driver redrawing it.

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.