Sizing Data Matrix Codes Exactly for Thermal Label Printers
Printing a Data Matrix code at a precise physical width is difficult because printers work in whole dots rather than millimetres. A module that should be 0.5 mm at 203 dpi falls at about 3.996 dots, so rounding each edge separately produces uneven module widths. The approach described rounds to a whole number of dots per module first and derives all other dimensions from that figure, which keeps modules identical at the cost of a slightly different overall size. The tool reports the actual module and code dimensions so the discrepancy is visible to the user. Encoding uses the bwip-js library, with its output captured as a raw module grid that can feed SVG, PNG and PDF exporters. The article also covers writing a PNG pHYs chunk so the image carries a physical resolution.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in