Pematuhan penjanaan kod bar, zon senyap, HRI, ECC mengikut ISO/AIM/GS1
Kebanyakan pemaparan kod bar, termasuk bwip-js, tidak menguatkuasakan pematuhan spesifikasi secara automatik. Mereka melukis apa yang dipanggil oleh pemanggil. Pemanggil perlu mengetahui lebar zon senyap yang betul, bendera HRI yang betul, tahap pembetulan ralat yang betul dan peraturan digit semak yang betul bagi setiap simbologi, kemudian menghantarnya. Halaman ini mendokumentasikan set pilihan yang dihantar Abundera mengikut jenis, piawai yang diterbitkan yang dipenuhi oleh setiap pilihan dan nombor bahagian di mana anda boleh mengesahkannya.
Mengapa pematuhan pemaparan penting
Industrial scanners do not guess. A Zebra DS3678 reading a Code 128 carton label expects a 10-X quiet zone on each side. Hand it 5 X and it rejects the read, every time. The label looks fine to a human. The scanner sees a corrupt symbol because the spec it was certified against says quiet zones are part of the symbol, not decoration around it. ISO/IEC 15417 §4.1 is explicit on this point, and every conformance lab tests against it.
Human-readable interpretation is not a stylistic choice in retail. ISO/IEC 15420 §4.4 requires the digits below an EAN-13 to be present and legible. A point-of-sale scanner that fails the laser read falls back to the cashier keying the digits; if HRI is missing, the cashier cannot complete the sale. A retailer who receives unmarked cartons from a supplier has standing to refuse the shipment.
Error correction is the margin between a code that survives the real world and one that does not. A QR Code at ECC level L tolerates roughly 7% damage; level H tolerates roughly 30%. Print contrast loss, ink bleed, fold creases, and oleophobic smudges all eat into that margin. Spec defaults exist because the standards bodies measured what fails in practice, and "what the library happens to default to" is not the same answer as "what ISO/IEC 18004 §7.5 recommends for a 25 mm code on coated stock."
The general posture: read the section number, set the option explicitly, do not rely on library defaults. Every value documented below is one we set on purpose and can defend against the relevant clause.
Jadual pematuhan mengikut simbologi
| Simbologi | Piawai | Zon senyap (setiap sisi) | HRI | ECC / digit semak | Lain-lain |
|---|---|---|---|---|---|
| QR Code | ISO/IEC 18004:2015 | 4 modules (top/bottom/left/right) | Not used | Reed-Solomon, levels L/M/Q/H (~7/15/25/30%) | Mode auto-selection (numeric, alphanumeric, byte, kanji) |
| Micro QR | ISO/IEC 18004:2015 Annex M | 2 modules (each side) | Not used | RS, levels L/M/Q only (no H); version M1 has fixed ECC | Single finder pattern; max version M4 (17×17) |
| rMQR | ISO/IEC 23941:2022 | 2 modules each side | Not used | RS, levels M and H | Rectangular; 32 size variants (R7×43 to R17×139) |
| Data Matrix | ISO/IEC 16022:2006 | 1 module each side | Not used | ECC 200 (Reed-Solomon, fixed; not user-selectable) | L-shaped finder + clock track; square or rectangular |
| Aztec | ISO/IEC 24778:2008 | None required | Not used | RS, 5%–95% selectable; 23% default, 50% for transit/IATA | Bullseye finder; rotation-invariant |
| PDF417 | ISO/IEC 15438:2015 | 2 modules each side (horizontal); 0 vertical | Not used (optional) | RS, security levels 0–8 (2 to 512 codewords) | Stacked linear; row height 3× module width minimum |
| AAMVA driver license | AAMVA Card Design Standard v10 | Per PDF417 (2 modules horizontal) | Not used | PDF417 ECC level 5 minimum (jurisdiction-set) | Compact PDF417 prohibited; mandatory element separators |
| Code 128 | ISO/IEC 15417:2007 | 10 X each side | Required if used; below symbol | Mod-103 check digit (calculated, not encoded as data) | Three subsets A/B/C; auto-shift for density |
| Code 39 | ISO/IEC 16388:2007 | 10 X each side | Optional; below symbol if shown | Mod-43 check digit optional (required by HIBC, LOGMARS) | Self-checking; * start/stop characters |
| Code 93 | AIM USS Code 93 | 10 X each side | Optional | Two mod-47 check digits (C and K), mandatory | Higher density than Code 39; 47 unique symbols + shifts |
| Codabar | AIM USS Codabar | 10 X each side | Optional | No check digit by spec; library/user can add mod-16 | Start/stop characters A/B/C/D; library-tracking heritage |
| EAN-13 | ISO/IEC 15420:2009 | Left 11 X, right 7 X | Required; specific 1-6-6 grouping below | Mod-10 check digit (13th digit) | Add-on 2/5 supplemental allowed (periodicals, books) |
| EAN-8 | ISO/IEC 15420:2009 | 7 X each side | Required; 4-4 grouping below | Mod-10 check digit (8th digit) | Reserved for small-package goods |
| UPC-A | ISO/IEC 15420:2009 | Left 9 X, right 9 X | Required; 1-5-5-1 grouping (first/last digit outside guard bars) | Mod-10 check digit (12th digit) | North American retail; equivalent to EAN-13 with leading 0 |
| UPC-E | ISO/IEC 15420:2009 | Left 9 X, right 7 X | Required; number system + 6 digits + check below | Mod-10, computed from expanded UPC-A equivalent | Zero-suppressed UPC-A; only specific manufacturer codes qualify |
| ITF-14 | ISO/IEC 16390:2007 | 10 X each side | Required; below symbol | GS1 mod-10 check digit (14th digit) | Mandatory bearer bars (top/bottom or full box); GTIN-14 carton mark |
| VIN | ISO 3779:2009 | Per carrier symbology (usually Code 39 or Data Matrix) | Required when printed; the 17-char VIN itself | Position-9 check digit (mod-11, North America) | 17 characters, uppercase, excludes I/O/Q |
QR Code
QR Code is the workhorse 2D symbology and the type with the most renderer-default trapdoors. The 4-module quiet zone is non-negotiable per ISO/IEC 18004 §6.3.3. Many libraries default to a smaller margin to save pixels in low-DPI use; we override that explicitly.
Error correction defaults to level M. We let the user upgrade to Q or H for printed codes that will live on a coffee cup or a sun-bleached window decal. We do not default to H because the data-density penalty is material and most digital-display QR codes do not need it.
qrcode.js library and apply a QUIET_ZONE_MODULES = 4 constant of margin around the finder grid. ECC defaults to user choice (L/M/Q/H) and auto-bumps to H whenever a logo, background image, or Swiss QR-bill payload is present.Micro QR
Micro QR is QR's small-payload sibling for very tight label real estate. ISO/IEC 18004 Annex M caps it at version M4 (17×17 modules) and forbids ECC level H. Quiet zone drops to 2 modules per Annex M §M.4. Our renderer enforces both, passing 4 modules of padding here would inflate the symbol footprint by 50% for no gain.
qrean library and manually paint QZ_MODULES = 2 modules of quiet zone around the bare module grid. ECC is forced to QR_ERRORLEVEL_L (Annex M's smallest allowed level for tightest payloads); Q and H are not exposed.rMQR
rMQR (rectangular Micro QR) is the 2022 ISO/IEC 23941 addition for narrow-strip applications: pharma vial labels, cable wraps, side-of-pill-pack marking. 32 size variants from R7×43 up to R17×139. Quiet zone is 2 modules. Only ECC levels M and H are defined; L and Q do not exist in this spec.
qrean library and manually paint QZ_MODULES = 2 modules of quiet zone around the grid. ECC is forced to QR_ERRORLEVEL_M; L and Q are not in the ISO/IEC 23941 spec and the UI does not surface them.Data Matrix
Data Matrix uses ECC 200, a fixed Reed-Solomon scheme with no user-selectable level. ISO/IEC 16022 §5.3 specifies a 1-module quiet zone, the smallest of any 2D symbology. The L-shaped finder and the dotted clock track on the opposite edges form the entire fiducial; nothing else is needed. For direct part marking on metal or plastic, ISO/IEC 29158 governs grading separately.
bcid: "datamatrix", scale: 4, paddingwidth: 8, paddingheight: 8. No ECC option is passed, Reed-Solomon ECC 200 is internal to the symbology.Aztec
Aztec is the only common 2D symbology that requires no quiet zone. The bullseye finder pattern in the centre is self-locating, so the symbol decodes even when cropped flush against another graphic. ISO/IEC 24778 §5.4 makes the zero-quiet-zone requirement explicit. Error correction is selectable from 5% to 95% of data codewords; we default to 23% (matches QR-M for general use) and recommend 50% for IATA boarding passes and transit tickets.
bcid: "azteccode", scale: 4, paddingwidth: 8, paddingheight: 8, eclevel: 23 (numeric percentage of data codewords reserved for ECC).PDF417
PDF417 is the only 2D symbology a 1D laser scanner can read, because it is a stack of linear rows. Quiet zone per ISO/IEC 15438 §5.8 is 2 modules left and right; the top and bottom can be flush. Security level (the spec's term for ECC) runs 0–8, where each level adds 2× the codewords of the previous. Level 5 is the AAMVA-mandated minimum for driver licenses; level 4 is typical for FedEx/UPS airbills.
bcid: "pdf417", scale: 4, paddingwidth: 16, paddingheight: 16, eclevel: 5. Columns and the compact-vs-full flag are passed through from the caller's _bwipOptsFor() selection when set; otherwise bwip-js auto-fits.AAMVA driver license
AAMVA driver licenses use PDF417 with additional constraints layered on top of ISO/IEC 15438. The Card Design Standard v10 forbids Compact PDF417 (which omits the right-side row indicators) and mandates a minimum security level of 5. Element separators (ASCII 0x0A line feed between subfile elements) are required, not optional. Our renderer treats AAMVA as a PDF417 variant with these constraints pre-set rather than as a separate symbology.
bcid: "pdf417", scale: 4, paddingwidth: 16, paddingheight: 16, eclevel: 5. The payload assembler emits the mandatory AAMVA header (@, line feed, ANSI , IIN, version) before subfile data; bwip-js does not see that as a separate option.Code 128
Code 128's quiet zone is 10 X (10 narrow modules) on each side per ISO/IEC 15417 §4.1. The mod-103 check digit is computed by the encoder, not supplied by the caller; misimplementations that ask the user to include the check digit produce double-checked symbols that reject. HRI is required when used, placed below the symbol per §4.4.
bcid: "code128", scale: 4, paddingwidth: 80, paddingheight: 0, includetext: true. Subset (A/B/C) auto-selection is bwip-js's default behaviour; we do not override it.Code 39
Code 39 is self-checking by design, so the mod-43 check digit is optional in the base spec, but mandatory under HIBC (Health Industry Bar Code) and LOGMARS (the US DoD adoption). 10 X quiet zone each side per ISO/IEC 16388 §5.5. The * start/stop characters are part of the symbol, not the data; encoders add them automatically.
bcid: "code39", scale: 4, paddingwidth: 80, paddingheight: 0, includetext: true. The mod-43 check digit is left to bwip-js's default (off); HIBC/LOGMARS callers that need it can layer the check at the payload level.Code 93
Code 93 always carries two check characters, C and K, both mod-47, computed and appended by the encoder. AIM USS Code 93 is the canonical spec; it is not an ISO standard but is the long-standing AIM publication every reader supports. Quiet zone 10 X each side. Higher density than Code 39, lower than Code 128, used where Code 39's symbol set is sufficient but space is tight.
bcid: "code93", scale: 4, paddingwidth: 80, paddingheight: 0, includetext: true. The C and K check characters are always added by bwip-js (no opt-out, per spec).Codabar
Codabar predates most ISO work; AIM USS Codabar is the controlling document. No check digit by spec, though library and blood-bank traditions add their own (Modulus 16 for blood-bag tracking). Start and stop are A/B/C/D characters chosen by the encoder. Quiet zone 10 X each side.
bcid: "rationalizedCodabar" (bwip-js's identifier for the modern variant), scale: 4, paddingwidth: 80, paddingheight: 0, includetext: true. Start/stop characters come from the caller's payload string, we do not pin them.EAN-13
EAN-13 is the global retail bar code. ISO/IEC 15420 §5.2.4.4 mandates asymmetric quiet zones: 11 X on the left, 7 X on the right. HRI is required and grouped 1-6-6: the leading digit sits in the left quiet zone, the next six under the left half, the last six under the right half. Mod-10 check digit is the 13th digit, computed by the encoder if the caller passes only 12.
bcid: "ean13", scale: 4, paddingleft: 44, paddingright: 28, paddingheight: 0, includetext: true, guardwhitespace: true. The asymmetric margins (44 px = 11 modules × 4 scale on the left, 28 px = 7 modules × 4 scale on the right) enforce the §5.2.4.4 quiet-zone requirement explicitly rather than relying on bwip defaults.EAN-8
EAN-8 is the small-package retail variant. Quiet zone 7 X each side per ISO/IEC 15420 §5.2.4.4. HRI is required, grouped 4-4. The 8th digit is the mod-10 check digit. EAN-8 numbers are issued by GS1 directly to applicants; they are not derived from EAN-13 by truncation.
bcid: "ean8", scale: 4, paddingwidth: 56 (7 modules × 4 scale × 2 sides), paddingheight: 0, includetext: true, guardwhitespace: true. bwip-js computes the check digit when 7 digits are supplied.UPC-A
UPC-A is the North American retail bar code, equivalent to EAN-13 with a leading 0. ISO/IEC 15420 §5.2.4.4 specifies 9 X quiet zones each side. HRI is grouped 1-5-5-1: the leading number-system digit sits to the left of the left guard bar, then five digits under the left half, five under the right half, and the check digit to the right of the right guard bar.
bcid: "upca", scale: 4, paddingwidth: 72, paddingheight: 0, includetext: true, guardwhitespace: true. The 1-5-5-1 HRI grouping is bwip-js's default for this bcid; we do not override.UPC-E
UPC-E is the zero-suppressed UPC-A variant for very small packages. Only specific UPC-A codes (those with manufacturer code patterns ending in 00000, 00001, 00002, or with trailing zeros) qualify for compression to UPC-E. The mod-10 check digit is computed from the expanded UPC-A equivalent, not from the displayed UPC-E digits. HRI shows the number system digit, six middle digits, and the check digit.
bcid: "upce", scale: 4, paddingwidth: 72, paddingheight: 0, includetext: true, guardwhitespace: true. Validation of the underlying UPC-A → UPC-E compression happens in the payload layer before bwip-js sees the input.ITF-14
ITF-14 is the GTIN-14 carton mark, the bar code on shipping cases that scans through shrink wrap. ISO/IEC 16390 specifies the Interleaved 2 of 5 base symbology; the GS1 General Specifications add the ITF-14 application: 14 digits, mod-10 check, 10 X quiet zones, and mandatory bearer bars. Bearer bars are the heavy black bars above and below (or fully boxing) the symbol. They prevent partial scans of a damaged or partially-occluded code from decoding as a different but valid GTIN.
bcid: "itf14", scale: 4, paddingwidth: 80, paddingheight: 0, includetext: true. The bearer bar is rendered by bwip-js's itf14 bcid at its default borderwidth; we do not override it.VIN
The Vehicle Identification Number is a 17-character alphanumeric string defined by ISO 3779. It is not itself a barcode; it is encoded as Code 39 (most common, NHTSA standard for under-the-hood labels) or Data Matrix (more common for newer assembly-line marking). Position 9 carries the check digit using a specific weighted mod-11 (North American) calculation. Letters I, O, and Q are excluded to avoid confusion with 1 and 0.
bcid: "code39", scale: 4, paddingwidth: 80, paddingheight: 0, includetext: true. The VIN's position-9 mod-11 check digit and the I/O/Q exclusion are enforced in the payload validator before the symbol is rendered, not via a bwip option.Rujukan
- ISO/IEC 18004:2015, QR Code bar code symbology specification (includes Annex M for Micro QR).
- ISO/IEC 23941:2022, Rectangular Micro QR Code (rMQR) bar code symbology specification.
- ISO/IEC 16022:2006, Data Matrix bar code symbology specification.
- ISO/IEC 24778:2008, Aztec Code bar code symbology specification.
- ISO/IEC 15438:2015, PDF417 bar code symbology specification.
- ISO/IEC 15417:2007, Code 128 bar code symbology specification.
- ISO/IEC 16388:2007, Code 39 bar code symbology specification.
- ISO/IEC 15420:2009, EAN/UPC bar code symbology specification.
- ISO/IEC 16390:2007, Interleaved 2 of 5 bar code symbology specification (the base spec ITF-14 sits on top of).
- AIM USS Code 93, Uniform Symbology Specification, AIM Global.
- AIM USS Codabar, Uniform Symbology Specification, AIM Global.
- GS1 General Specifications (current edition; freely downloadable from gs1.org). Application-layer rules for ITF-14 bearer bars, GS1 element strings, GS1 Digital Link.
- AAMVA Card Design Standard (current version), American Association of Motor Vehicle Administrators.
- ISO 3779:2009, Road vehicles, Vehicle identification number (VIN), Content and structure.
Lihat juga
- Standards index, back to the reference hub.
- Aztec reference, full per-spec breakdown for the boarding-pass symbology.
- PDF417 reference, the stacked-linear sibling.
- Data Matrix reference, direct part marking and pharma.
- Aztec · PDF417 · Data Matrix comparison, when to pick which.