^BX generates a Data Matrix barcode, a 2D matrix code known for high data density in a very small footprint. Data Matrix is widely used in pharmaceutical (GS1 DataMatrix for drug tracing), aerospace (ATA 2000 spec), and electronics manufacturing for part marking.
Data Matrix can encode alphanumeric, ASCII, and binary data. A 22×22 symbol can encode up to 30 characters; a 144×144 symbol can encode up to 3116 numeric digits or 2335 text characters. This density makes it suitable for very small labels (down to 1mm² with industrial marking).
The dimension parameter (h) sets the module size in dots — unlike ^BQ (QR Code) which uses a separate magnification factor, ^BX uses h as both height of each module and implicitly controls the overall symbol size in combination with symbol size (s and c parameters). Setting h to 3 at 203 DPI gives 3-dot (≈15 mil) modules.
Data Matrix uses ECC 200 error correction by default, which provides up to 30% error recovery. This means even a significantly damaged symbol (scratched, dirty) can still be read if the damage doesn't exceed the ECC threshold.
For GS1 DataMatrix (pharmaceutical serialization like DSCSA, SNDC), the data must include the appropriate Application Identifiers (01, 17, 10, 21) with proper FNC1 encoding.
Syntax
^BXo,h,s,c,r,f,g
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| o | N | R | I | B | N | Orientation: N = normal, R = 90°, I = 180°, B = 270°. |
| h | integer | optional | Height of each individual module (cell) in dots. |
| s | integer | 200 | Symbol size: 0 = auto-size (smallest that fits data), or a specific Data Matrix size code (e.g., 200 = 10×10 up to 144×144). |
| c | integer | 200 | Columns per region. Used for rectangular Data Matrix symbols. |
| r | integer | 0 | Rows per region. 0 = auto. |
| f | string | ~ | Format ID — tilde character in most implementations. |
| g | integer | 1 | Aspect ratio: 1 = square, 2 = rectangular. |
Examples
Auto-sized Data Matrix encoding a product code
Try in Viewer^XA ^FO50,50^BXN,3,200^FDPROD-ABC-001234^FS ^XZ
Data Matrix with larger modules for easy scanning
Try in Viewer^XA ^FO50,50^BXN,5,200^FDINV-2026-98765^FS ^XZ
Common Mistakes
- !Setting module size (h) too small — at 1-2 dots at 203 DPI the symbol is too small for most industrial scanners.
- !Using Data Matrix for consumer retail labels — QR Code or EAN/UPC are expected by retail POS systems.
- !Forgetting FNC1 encoding for GS1 DataMatrix — pharmaceutical/GS1 use requires specific Application Identifier formatting.