Code 128 and retail barcodes

A barcode that does not scan stops the pallet at the door and the queue at the till. It fails for reasons nobody can see by looking — a check digit one out, bars a shade too thin because the code was saved as a picture and then resized, a white margin somebody trimmed off to make it fit.

Two different jobs sit on the same page here. Code 128 takes any text at all — a works order, a batch number, a shelf reference — and packs it into the narrowest strip that text allows. The retail three are the opposite: EAN-13, UPC-A and EAN-8 each carry a fixed count of digits and nothing else, because a till reads them and a till expects exactly that. Their last digit is not one you pick either — it is worked out from the ones in front of it, and a wrong one is the commonest reason a code is turned away at a checkout. Stripes like these are the choice when the thing reading them is a laser at a counter or a loading bay; when the message is longer than a number, the square codes further along this family carry far more.

What this example shows

  • One code that takes any text at all, packed as tightly as that text allows.
  • The three codes a till reads, each with its last digit worked out rather than typed.
  • Bars drawn line by line, not a photograph of a barcode.

The source code, complete

Nothing is left out and nothing is simplified: this is the program exactly as it runs, for the developer who uses this library. The third is the description itself: a plain list of what the page has to say, which is what the service is sent.

Read the Rust source Read the Python source Read the JSON source

The document itself

Open the document in English Open the document in French

Examples near this one

QR codes

The code an invoice, a boarding pass or a label ends up wanting, drawn into the document rather than fetched as a picture and pasted in.

Data Matrix codes

The code industry marks small parts with: still readable at sizes where a QR code has given up, on a circuit board or a phial in a laboratory tray.

PDF417 codes

The code on identity documents and shipping papers: it carries far more text than a row of bars, and it survives a laser scanner dragged across it.

Aztec codes

The code on rail and airline tickets, and the reason is room: it needs no band of white around it, which is the first thing trimmed off a layout that has run tight.

A gallery of picture formats

The four picture formats read — JPEG, PNG, BMP and TIFF — shown across every picture shipped with the library, each captioned with what its own file declares.

Every example, by subject