ZPL2 to PDF: what ZPL II is and how to convert it
Updated · Rotomal
ZPL II, often written ZPL2 or ZPLII, is version 2 of Zebra Programming Language and the version Zebra printers use by default, so a file labelled ZPL2 converts like any current ZPL file. To turn it into a PDF, render each ^XA … ^XZ block at the density the label was written for (usually 8 dots per mm, 203 dpi) and at the label size (usually 4 x 6 inches), then save all labels into one PDF. Labelary's API does this when you request PDF and leave the label index out of the URL.
ZPL, ZPL II, ZPL2, ZPLII: the same thing today
Zebra's ^SZ (Set ZPL) command chooses between two versions: 1 for the original ZPL and 2 for ZPL II, and the default is 2. Shipping software writes the name in different ways, for example ZPLII in NetSuite's FedEx and USPS label settings, but in practice it means the current language. You do not need a separate ZPL2 converter.
How a ZPL II label is built
- Every label format starts with ^XA and ends with ^XZ. Zebra's programming guide says valid ZPL II format requires both.
- Between them, field commands place text, barcodes and graphics, for example ^FO (field origin), then ^FD (field data) and ^FS (field separator).
- ^PW sets the print width and ^LL the label length, both in dots.
- A file can hold many ^XA … ^XZ blocks one after another. Each block is one label and should become one page of the PDF.
Pick the right density (dpmm) and size
Because ZPL measures in dots, the PDF is only the right size if you render at the density the label was written for. Zebra's ^JM page lists 24, 12, 8 and 6 dots per mm as the full-resolution settings, and Labelary's API accepts 6, 8, 12 and 24 dpmm, with label width and height up to 15 inches.
| Dots per mm | About dots per inch | Where you see it |
|---|---|---|
| 6 dpmm | 152 dpi | Older or low-cost printers |
| 8 dpmm | 203 dpi | Most desktop shipping label printers |
| 12 dpmm | 300 dpi | Industrial printers, small barcodes |
| 24 dpmm | 600 dpi | Very small labels and fine print |
Most carrier labels are 4 x 6 inches at 8 dpmm. If the PDF looks too small or too large, change the density before you change the file.
Convert a multi-label ZPL2 file to one PDF
Labelary's documentation says its API can return every label in a ZPL file as a single PDF; this works only for PDF output. The free tier allows 50 labels per request, so larger files have to be split into chunks.
Checks before you print
- Count the pages in the PDF: it should match the number of ^XA blocks in the file.
- Print at 100% or Actual size, with Fit to page turned off, or the barcodes may not scan.
- If a logo or block is missing, the label recalls a graphic or format stored in the printer; include the file that downloads it.
- Labelary's documentation says unsupported commands are skipped rather than stopping the render, so compare the PDF with a real printed label the first time.
If you want this done for you
Label Render converts ZPL II batches to PDF by upload, email, watch folder or API, one page per label, with a report of anything it could not render, and deletes your files after conversion. Plans start at $5 a month. Still on EPL? See https://rotomal.com/epl-to-pdf/
Questions
Is ZPL2 different from ZPL?
ZPL II is version 2 of ZPL and the default on Zebra printers, per Zebra's ^SZ command. Any current ZPL converter reads it.
What density should I use for ZPL2 shipping labels?
Start with 8 dpmm (203 dpi) and 4 x 6 inches; if the content runs off the edge or looks about one and a half times too big, the label was written for 12 dpmm (300 dpi).
Can I convert ZPL2 to PDF without a Zebra printer?
Yes. A renderer draws the label from the code; no printer is involved. Online viewers, Labelary's API, open-source tools and Label Render all work this way.
Sources
- Zebra ZPL programming guide: ^SZ Set ZPL Source: docs.zebra.com
- Zebra ZPL programming guide: ^XA Start Format Source: docs.zebra.com
- Zebra ZPL programming guide: ^JM Set Dots per Millimeter Source: docs.zebra.com
- Zebra ZPL programming guide: ^PW Print Width Source: docs.zebra.com
- Zebra ZPL programming guide: ^LL Label Length Source: docs.zebra.com
- Labelary: Label API documentation, limits and plans Source: labelary.com
- Labelary: ZPL rendering documentation Source: labelary.com
- Oracle NetSuite: printing integrated shipping labels with a thermal printer Source: docs.oracle.com