ZPL guide 6 of 9
2D codes: QR Code, Data Matrix, PDF417
How to print QR Code, Data Matrix and PDF417 in ZPL, with the data switches QR needs inside ^FD, plus a short guide to Aztec, MaxiCode and MicroPDF417 and where the guide contradicts itself.
Linear versus 2D, and what ZPL supports
Question Which 2D codes does ZPL support?
A linear code is read along one line of bars. A 2D code stores data across an area, so it can hold much more in less width.
The guide lists these 2D codes: Aztec, Code 49, MaxiCode, TLC39, PDF417, QR Code, Codablock, Data Matrix and MicroPDF417.p. 1586
This guide covers three of them, QR Code (^BQ), Data Matrix (^BX) and PDF417 (^B7), then touches on Aztec, MaxiCode and MicroPDF417.
Sizing works differently from linear codes. ^BQ has its own magnification factor and ^BX its own element size. For ^BX the module width and ratio from ^BY have no effect, and ^BY height is used only if you leave the element size out. For ^BD, ^BY has no effect at all, while for ^B7 it still supplies the module width.pp. 82, 106, 128, 144, 146
QR Code with ^BQ
Question How do I print a QR Code, and what does the data string need to contain?
^BQ takes an orientation that is always normal (^FW has no effect), a model (1 or 2; model 2 is recommended and the default), a magnification factor from 1 to 100, an error-correction level and a mask value from 0 to 7.p. 128
The default magnification depends on the printer's resolution: 1 at 150 dpi, 2 at 200, 3 at 300 and 6 at 600. The error-correction levels are H (ultra-high reliability), Q (high), M (standard) and L (high density).p. 128
The part that catches people out is the data. A QR code's ^FD string starts with switches, in a fixed order: an optional mixed-mode switch, then the error-correction level, then the data-input mode followed by a comma, then, only for manual input, a character mode. The data itself follows immediately after the last switch.pp. 129, 130
The basic form is the level, the letter A for automatic input and a comma, then your text. With manual input (M) you must give the character mode: N for numeric, A for alphanumeric, a byte mode written B followed by exactly four digits, or K for Kanji.pp. 130 to 132
WarningIn automatic input the byte values 0x80 to 0x9F and 0xE0 to 0xFF cannot be used.p. 130
WarningThe guide contradicts itself on the default error-correction level. The parameter table gives Q when the parameter is empty (M for an invalid value), while the switch description calls M the default. Do not rely on either: always send the level explicitly in the switch.pp. 128, 129
^XA ^FO40,40^BQ,2,6 ^FDQA,Bin A17 lot 0042^FS ^XZ
Model 2, magnification 6. The data begins with Q (error-correction level) and A, (automatic input), then the text.
Data Matrix with ^BX
Question How do I print a Data Matrix?
^BX takes an orientation, the size in dots of each square module, and a quality level of 0, 50, 80, 100, 140 or 200 (how much error-correction data is added; the default is 0). The guide recommends quality 200 (ECC 200) for new applications and says the lower levels belong only in closed systems where one party controls both printing and reading.p. 144
Rows and columns are worked out automatically, and you can force larger ones. At quality 200 only even values are valid.p. 144
At quality 200 the field data may contain escape sequences, introduced by an escape character: an underscore on firmware V60.13.0.12 or later, a tilde before that, or any character you choose in the g parameter. A literal underscore is written as two on newer firmware. Avoid the escape character in plain data.pp. 145 to 147
At quality 200, data beyond 3072 bytes is truncated. The guide gives maximum capacities of 2335 alphanumeric characters and 1556 bytes of 8-bit data.p. 146
^XA ^FO40,40^BXN,6,200 ^FDBin A17 lot 0042^FS ^XZ
Normal orientation, 6-dot modules, quality 200.
PDF417 with ^B7
Question How do I print PDF417, and what is its data limit?
PDF417 is a stacked code of 3 to 90 rows, able to hold over a thousand characters. Field data is limited to 3K.p. 79
^B7 takes an orientation, a row height value (the guide says it is multiplied by the module width to give the row height in dots), a security level from 1 to 8 (the default 0 gives error detection only), and optional column and row counts. If you set both, their product must stay below 928 or no symbol prints; the guide does not say what happens at exactly 928. A truncation option shortens the right edge.pp. 79 to 81
WarningThe ^B7 page lists the ^BY module width as 2 to 10, where the ^BY page says 1 to 10, so use a module width of at least 2 with PDF417.pp. 82, 148
Inside the data, \& is a carriage return and line feed, which is how you encode multi-line content. Serialization is not allowed with this code.p. 82
^XA ^FO40,40^BY2 ^B7N,10,3 ^FDBin A17 lot 0042^FS ^XZ
Module width 2 from ^BY, a row height value of 10 and security level 3.
Aztec, MaxiCode and MicroPDF417
Question What about Aztec, MaxiCode and MicroPDF417?
Aztec has two entries, ^B0 with a digit zero and ^BO with a letter O. Their descriptions and seven parameters read the same, and the guide's table lists both as Aztec parameters. The guide does not say which to prefer. It needs firmware V60.13.0.11A or V50.13.2 or later.pp. 64, 124, 1587, 1588
MaxiCode (^BD) has modes 2 to 6 with 2 as the default, and in modes 2 and 3 the data must follow a strict postal-code layout. Mode 3 is for non-U.S. codes, and the printer does not switch modes for you. It has no interpretation line.pp. 106 to 108
MicroPDF417 (^BF) is a compact PDF417 variant of up to four columns by 44 rows. A mode from 0 to 33 selects the size, and data is limited to 250 7-bit, 150 8-bit or 366 numeric characters.pp. 111 to 113
For special characters in any of these, ^FH lets you write a hexadecimal value in ^FD.pp. 108, 193
The same label with BarcoderX
Question Where does BarcoderX fit in?
BarcoderX is pre-launch and its API is not final. It is designed to let you describe the label once in .NET and emit ZPL or EPL. QR Code, Data Matrix and PDF417 belong to the Ultimate edition; see Pricing. The published samples on the Developers page do not show 2D code calls yet, so there is no code here.
Questions
Why does my QR code not print what I sent?
The ^FD string for ^BQ must begin with the switches: the error-correction level and the data-input mode, for example QA, followed by your text.pp. 129, 130
Which Data Matrix quality should I use?
The guide recommends quality 200 (ECC 200) for new applications.p. 144
Should I use ^B0 or ^BO for Aztec?
The guide documents both with identical parameters and does not say which is preferred.pp. 64, 124
Commands in this guide
- ^BQQR Code BarcodePrints a QR Code symbol from the data of the next field; the field data must begin with switches that select the error-correction level and the input mode.
- ^BXData Matrix BarcodePrints a Data Matrix symbol, a two-dimensional code of square modules inside a perimeter finder pattern, from the data of the next field.
- ^B7PDF417 Bar CodePrints a PDF417 symbol, a two-dimensional stacked code of three to 90 rows, from the data of the next field.
- ^B0Aztec Barcode ParametersPrints an Aztec symbol, a two-dimensional matrix code of square modules around a central bulls-eye. Written with the digit zero; the guide also documents a letter O form, ^BO.
- ^BOAztec Bar Code ParametersPrints an Aztec symbol, a two-dimensional matrix code of square modules around a central bulls-eye. Written with the capital letter O; the guide also documents a digit zero form, ^B0.
- ^BDUPS MaxiCode Bar CodePrints a UPS MaxiCode symbol, a two-dimensional code developed by UPS and read optically, with no interpretation line; modes 2 and 3 expect a structured message.
- ^BFMicroPDF417 BarcodePrints a MicroPDF417 barcode, a stacked two-dimensional code like PDF417 but with narrower row address patterns, in one of 34 row-and-column modes.
- ^BYBar Code Field DefaultSets the module width, the wide-to-narrow bar ratio and the bar height that later barcode commands fall back on, until the next ^BY is received.
- ^FOField OriginSets where the next field starts: the position of the field's upper-left corner, counted in dots from the label home position.
- ^FDField DataDefines the data string of a field: the text or barcode data that the field carries.
- ^FHField Hexadecimal IndicatorLets the field data that follows contain hexadecimal values for characters. A marker character, an underscore by default, introduces each value.
- ^FSField SeparatorMarks the end of a field definition, so the commands that follow start a new field.
- ^FWField OrientationSets the default rotation, and on newer firmware the default justification, for the fields that follow it.
- ^XAStart FormatOpens a label format. A valid ZPL II format starts with ^XA and ends with ^XZ.
- ^XZEnd FormatCloses a label format. When the printer receives it, a label prints.
Related guides
Linear barcodes: Code 128, Code 39, EAN, UPC and more What is ZPL? The anatomy of a label Text and fonts in ZPL Label size, quantity and printer settingsBarcoderX is a .NET SDK for thermal labels and barcodes. See the barcode types it covers.
Source Zebra, ZPL II, ZBI 2, Set-Get-Do, Mirror, WML Programming Guide, P1134473-11EN Rev A, 2026/07/05, pages 64, 79 to 82, 106 to 108, 111 to 113, 124, 128 to 132, 134, 144 to 148, 193, 1586 to 1588.
Written by BarcoderX in its own words. Checked against the guide on 2026-11-14.
ZPL and ZPL II are trademarks of Zebra Technologies Corporation. This reference is written by BarcoderX in its own words from Zebra's published programming guide. BarcoderX is an independent product and is not affiliated with, endorsed by or sponsored by Zebra Technologies.