Datamatrix is the matrix format of choice for marking small parts: the solid L-shaped finder and the alternating timing pattern along the other two edges give a reader the grid from a symbol only 10 modules square.
Six encoding schemes cover different payload shapes, from ASCII through the compacted C40, TXT and X12 sets to raw BASE256, and the encoder picks between them unless told otherwise. The GS1 variant prefixes the payload with FNC1 so the data reads as an element string.
Type Token
| Item | Value |
|---|---|
| Type token | DATAMATRIX |
| Enum case | BarcodeType::DATAMATRIX |
| Family | 2D |
| Standard | ISO/IEC 16022 |
| Class | \Com\Tecnick\Barcode\Type\Square\Datamatrix |
Input
| Item | Value |
|---|---|
| Character set | any byte sequence |
| Length | up to 3116 digits or 2335 ASCII characters |
| Check | Reed-Solomon error correction, computed by the library |
| Extra parameters | 2 (see below) |
Extra Parameters
Appended to the type token after commas, as in DATAMATRIX,R.
| Position | Meaning | Values | Default |
|---|---|---|---|
| 1 | symbol shape | S square, R rectangular | S |
| 2 | encoding scheme | ASCII, C40, TXT, X12, EDF, BASE256, or GS1 | ASCII |
Examples
A square symbol
<?php
require_once __DIR__ . '/vendor/autoload.php';
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
type: 'DATAMATRIX',
code: '0123456789',
width: -4,
height: -4,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
echo $bobj->getInlineSvgCode();
A rectangular symbol
$bobj = $barcode->getBarcodeObj(
type: 'DATAMATRIX,R',
code: '0123456789012345678901234567890123456789',
width: -4,
height: -4,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
GS1 mode, with FNC1 opening the element string
$bobj = $barcode->getBarcodeObj(
type: 'DATAMATRIX,S,GS1',
code: \chr(232) . '01095011010209171719050810ABCD1234' . \chr(232) . '2110',
width: -4,
height: -4,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
Errors
These payloads raise \Com\Tecnick\Barcode\Exception:
| Payload | Message |
|---|---|
| `` | Empty input |
See Also
- tc-lib-barcode : the library overview.
- Rendering Options : size, colour, padding.
- Output Formats : every renderer.
- Data Matrix Rectangular Extension : the rectangular extension, with more sizes.
- HIBC in Datamatrix : a Datamatrix carrying an HIBC data structure.
- QR Code : the other widely used matrix format.
- API reference : the generated class documentation.