A Data Matrix code, very small and very sturdy
Draw a Data Matrix code, the one on parcels and small parts: as much content as a QR code in far less room.
Summary
You find it on parcels, on medicine bottles, and engraved straight onto machined parts — which is what makes it the favourite of tiny labels. You give the text and the frame, and the square is drawn with its white margin on all four sides. Where the label is a thin strip rather than a square — a sample tube, a component, a strip of adhesive — you ask for the oblong shape instead, and the code follows it. It copes well with dirt and light scratches, which helps when the label travels.
Technically
Asked for with
"type": "data_matrix"
Encoding follows the ASCII scheme at ECC 200, the standard's modern correction, and the modules are drawn as filled squares in the page content stream. The symbol and its quiet zone on all four sides fill the rectangle's width, anchored at the lower-left corner: the width commands, the rectangle's height is headroom. Absent any word on it, the symbol is the smallest square that carries the text, from 10 by 10 modules to 144 by 144. An oblong symbol may be asked for instead — the smallest of the six the standard carries, from 8 by 18 to 16 by 48 — and being wider than it is deep, it leaves the top of the rectangle empty. The exact symbol may also be stated in modules, down and across, so a run of labels comes out one size whatever each carries. Stating the shape and the exact symbol both is refused, and text longer than the symbol asked for carries answers 400. Like the other codes, the item draws the symbol alone.
Request schema
Required keys: content, a string; rect. Optional: shape, either square (default) or rectangle; size, an object of height and width in modules, the symbol taken exactly as stated however little of it the text fills; pages, an array of one-based integers, default empty; transform, six numbers; rotate, degrees counter-clockwise about the centre of the rectangle; layer, the name of a declared layer. Cross refusals: transform together with rotate, and shape together with size. The encoding scheme and the correction level are fixed at the ASCII scheme and ECC 200.
A whole request that creates a PDF
{
"items": [
{
"type": "data_matrix",
"content": "SN:2026-08-08/ACME-4472",
"shape": "square",
"rect": {"llx": 72, "lly": 700, "urx": 132, "ury": 760}
}
]
}
Barcodes and square codes
A barcode of vertical bars A square QR code, read with a phone An Aztec code, with no white margin around it A PDF417 code, carrying a whole form
Where to go next
Every JSON key of a request, in one page The other twenty-two things you can draw