82label

Docs › Barcodes and QR

Barcodes

Code128, EAN-13 and 8, UPC-A, Code39, ITF, ITF-14: check digits and scannable sizes.

A barcode is one element. The value alone is enough: without a position it goes in the middle of the label, 80% wide.

{ type: 'barcode', value: '{{sku}}' }                       // Code 128, centred
{ type: 'barcode', x: 3, y: 14, w: 44, h: 13, format: 'ean13', value: '{{ean}}', showText: true }

Drawn by the real library

Code for this example

Label82.barcodeSVG('880123456789', { format: 'ean13', height: 18 })

Formats

formatValueUsed for
code128Digits, letters, symbols, any lengthThe default. SKUs, order numbers, waybills. Long digit runs switch to the dense C set automatically.
ean1312 digits (+1 check)Retail product barcodes. Give 12 digits and the check digit is added; give 13 and it is verified.
ean87 digits (+1 check)Small products.
upca11 digits (+1 check)North American retail.
code39Upper-case letters, digits, - . space $ / + %Older in-house systems, asset tags.
itf1413 digits (+1 check)Shipping cartons (GTIN-14).
itfAn even number of digitsInterleaved 2 of 5 with no check digit. Hanjin and Lotte tracking numbers.

Invalid values

A value that does not fit the format (wrong EAN length, lower case in Code39 …) is drawn as a crossed box and reported in the print result's errors. To check ahead, call encodeBarcode.

import { encodeBarcode, eanCheckDigit, BarcodeError } from '@82label/core';

eanCheckDigit('880123456789'); // 3 → 8801234567893
try {
  encodeBarcode('ean13', '88012345');
} catch (e) {
  if (e instanceof BarcodeError) console.log(e.message);
}

const r = await Label82.print(template, rows);
r.errors; // [{ element: 2, code: 'barcode_invalid', message: '…' }]

Sizes that scan

  • The narrow bar (module) is snapped to whole printer dots (paper.dpi). At 203 dpi a dot is 0.125 mm.
  • Keep a quiet zone of ten modules on each side; do not run the barcode to the label edge.
  • Make it at least 10 mm tall; 15 mm or more for barcodes read from a distance, like waybills.
  • A long value in a narrow box pushes modules below 0.19 mm and scanners struggle. The designer warns you.

A barcode on its own

Need only the barcode picture? barcodeSVG returns an SVG string for a screen or a PDF.

Label82.barcodeSVG('EP-2026-0412', { height: 15, showText: true });
Label82.barcodeSVG('880123456789', { format: 'ean13', moduleWidth: 0.33 });