내용으로 건너뛰기

Data Matrix codes in ZPL with ^BX

To print a Data Matrix code in ZPL, use ^BXN,{module size},200 and the data: ^FO60,40^BXN,8,200^FDOZ-2026-0042^FS. The second parameter is the size of each square in dots, and 200 selects ECC 200, the error correction that current scanners read.

2026-10-20에 업데이트됨 · Renders made with the OpenZPL engine

Open in the viewer

Generator

렌더링 중...

4 × 2 in label at 203 dpi. A preview shows how the printer draws the code; confirm with a scanner before printing a run.

The ^BX command

매개변수그 기능값
^BX oOrientationN, R, I, B
^BX hModule size: dots per square1 up to the label width
^BX sError correction200 (ECC 200); 0 to 140 are the legacy levels
^BX c, rColumns and rowsempty = the smallest symbol that fits the data
Data Matrix code for OZ-2026-0042, 112 dots square
4 × 2 in label at 203 dpi (8 dpmm) · 812 × 406 px · Open in the viewer
^XA
^FO60,40^BXN,8,200
^FDOZ-2026-0042^FS
^XZ

Size in dots

The printer picks the smallest symbol that fits the data, and the module size scales it. Measured on OpenZPL renders at 203 dpi:

DataSymbolModule sizeSize in dots
OZ-2026-0042 (12 characters)14 × 14456 × 56
OZ-2026-004214 × 148112 × 112
OZ-2026-0042, columns and rows set to 2222 × 228176 × 176
https://openzpl.com/barcodes/data-matrix/ (41 characters)24 × 245120 × 120

Data Matrix fits a lot in a small square, which is why it is used on small parts and healthcare products. Keep at least 4 dots per module at 203 dpi so the printer can draw each square cleanly.

ECC 200 versus the legacy levels

Use 200. Levels 0 to 140 are an older format; our test code with level 0 rendered, but zxing-cpp, a common open-source decoder, could not read it, and many scanners can't either.

^BXN,8,0 (legacy, not read by our decoder)

The same data with legacy error correction 0, drawn as a different pattern
4 × 2 in label at 203 dpi (8 dpmm) · 812 × 406 px · Open in the viewer
^XA
^FO60,40^BXN,8,0
^FDOZ-2026-0042^FS
^XZ

^BXN,8,200 (ECC 200)

Data Matrix code for OZ-2026-0042, 112 dots square
4 × 2 in label at 203 dpi (8 dpmm) · 812 × 406 px · Open in the viewer
^XA
^FO60,40^BXN,8,200
^FDOZ-2026-0042^FS
^XZ

Valid and invalid data

  • Any text, digits or URLs. Escape ^ and ~ with ^FH; see special characters in data.
  • For GS1 Data Matrix (healthcare, some retail), the data needs the FNC1 character and GS1 application identifiers; check the Zebra guide for the escape sequence your printer uses before printing.
  • If you fix columns and rows too small for the data, the printer cannot fit it; leave them empty unless a specification requires a size.

Check a barcode before printing a run

A preview shows how the printer will draw the code: bar widths, quiet zone and the human-readable line. It does not prove that every scanner reads it on your media. Print one label at the real density and scan it with the scanner your customer or carrier uses; for retail and logistics codes, a barcode verifier grades the print quality.

질문

Data Matrix or QR code?

Both are 2D codes. Data Matrix is more compact for short data and common in industry; QR codes are what phone cameras expect for URLs. See QR codes in ZPL.

How do I make a Data Matrix code bigger?

Raise the module size, the second parameter of ^BX: ^BXN,10,200.

Sources