Linear (1D) / Codabar
Codabar barcode in a PDF
An old numeric symbology with no check digit of its own and four different start and stop characters, which are chosen by the application rather than by the data.
Where the symbol comes from
This API renders HTML to PDF. It does not generate barcodes, so the Codabar symbol itself is produced by an encoder in your own stack and placed in the markup, either as inline SVG or as a data URI. That split matters more than it sounds: the encoders are mature and correct, and almost every barcode that will not scan failed for a layout reason rather than an encoding one. Everything below is about the layout half.
What it can encode
The digits 0 to 9 and the six characters minus, dollar, colon, slash, full stop and plus. Nothing else: no letters inside the data. Length is variable. What makes it unusual is that every symbol is wrapped in a start and a stop character drawn from a set of four, written A, B, C and D (some equipment writes the same four as T, N, star and E), and that pair is part of the symbol.
The check digit, and who computes it
None in the base specification, which is the single most important fact on this page. Applications bolt one on and they do not agree: blood banking uses a modulo 16 check character, some library systems use a modulo 10 over the digits, and plenty of deployments use nothing at all. Your encoder will almost certainly not add one, so if the receiving system expects a check character it is your data that has to carry it.
Size and quiet zone
The two measurements that decide whether a scanner accepts the symbol, and the two most often lost when a design is adjusted to fit.
- X-dimension: 0.19mm to 0.25mm as a practical floor. It is a two-width symbology and the wide to narrow ratio has to stay between 2.0 to 1 and 3.0 to 1. That ratio is the constraint people break, because it survives uniform scaling and does not survive anything else.
- Quiet zone: 10 times the X-dimension at each end, minimum 6.4mm. Codabar is often printed on narrow stock, a specimen tube label or a book spine, where the temptation to run the symbol to the edge is strongest.
Where it is used
- blood bank and transfusion labelling, where legacy systems predate anything newer
- library circulation, on patron cards and item labels
- photo finishing and film processing envelopes
- legacy air waybills and courier documents that were never migrated
Placing it in the markup
The quiet zone is padding on the container rather than part of the encoder's output, so it survives a change of encoder. Dimensions are in millimetres, because a bar width is a physical measurement and a percentage makes it depend on whatever the container happens to be.
<!-- The start and stop characters are chosen by the receiving
system, not by you and not by the encoder's default. Get the pair
wrong and the symbol scans perfectly and the data is rejected. -->
<figure class="codabar">
<img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0i..." alt="Specimen 3910447">
<figcaption>A3910447B</figcaption>
</figure>
<style>
.codabar {
margin: 0;
padding: 0 7mm;
width: max-content;
}
.codabar img {
width: 46mm;
/* Tall relative to its width, because these end up on tube labels and
spines where the scan line crosses at whatever angle it can. */
height: 20mm;
display: block;
}
.codabar figcaption {
/* The start and stop characters shown, because two systems reading the
same tube can be configured to strip them or to keep them. */
font: 9pt/1.2 "IBM Plex Mono", monospace;
text-align: center;
margin-top: 1.5mm;
}
</style>What goes wrong on paper
The start and stop pair. An encoder defaulting to A and B will happily produce a symbol for a system expecting A and A, and the scan succeeds, so nothing looks wrong until the receiving application rejects the value. Fix the pair in your encoder call rather than trusting a default, and print it in the human readable line so the mismatch is visible to a person.
First thing to check when it will not scan
Find out whether the scanner is configured to transmit or to strip the start and stop characters, because the two settings produce different strings from an identical symbol and the difference usually surfaces as a data problem rather than as a scan problem. After that, check the wide to narrow ratio: anything outside 2 to 1 through 3 to 1 is out of specification even if it looks fine.
Vector, not a bitmap
Encode to SVG wherever the encoder offers it. A rasterised barcode is resampled when the PDF is printed, and at 203 or 300 dots per inch the bar edges land between printer dots, so the ratio of bar to space drifts by a fraction of a millimetre. That fraction is the whole tolerance. An SVG stays vector inside the PDF and is rendered at the printer's own resolution, which removes the entire failure mode. Where a bitmap is unavoidable, generate it at the final physical size and set image-rendering so nothing smooths the edges.
Frequently asked
Does this API generate Codabar symbols?
No. It renders HTML to PDF. The symbol is produced by a barcode library in your own application and embedded in the markup as SVG or as a data URI, which is the same way you would put any other generated graphic into a document. What this API is responsible for is that the symbol reaches the page at the size and position you specified.
Why does it scan on screen and fail on paper?
Three reasons, in order of frequency. The quiet zone is present on screen because the browser window is white and absent on paper because the label is not. The symbol was sized as a percentage, so it came out at a different physical width than the one that was tested. Or it is a bitmap, and printing resampled it so the bar-to-space ratio moved outside tolerance.
Can I scale the symbol to fit the space I have?
Uniformly, within the range the symbology allows, and never on one axis. 0.19mm to 0.25mm as a practical floor. It is a two-width symbology and the wide to narrow ratio has to stay between 2.0 to 1 and 3.0 to 1. That ratio is the constraint people break, because it survives uniform scaling and does not survive anything else. is the constraint on the way down. Scaling one axis changes the bar-to-space ratio on a linear symbology and makes a 2D symbol non-square, and neither survives a scanner.
Other symbologies
Codes of the same kind, and one from each of the other kinds.
Code 128 barcode in a PDF
The general-purpose linear barcode: full ASCII, any length, and the densest of the common linear symbologies for numeric data.
GS1-128 barcode in a PDF
Code 128 with a data structure on top: a function character marks the symbol as GS1, and the content is a sequence of Application Identifiers.
EAN-13 barcode in a PDF: sizing and quiet zones
The retail barcode used everywhere outside North America: thirteen digits, a fixed size range, and an asymmetric quiet zone.
UPC-A barcode in a PDF
The North American retail barcode: twelve digits, and technically a subset of EAN-13 with a leading zero.
PDF417 barcode in a PDF
A stack of short linear rows rather than a matrix: high capacity, a wide flat shape, and the symbology behind driving licences and boarding passes.
QR code in a PDF
The 2D code everyone recognises: read by any phone, generous error correction, and a quiet zone four modules wide that almost nobody leaves.
Every symbology, with its quiet zone
The full list, grouped by whether the code is linear, stacked or a matrix.
4x6 shipping label PDF size
The label most of these end up on, with the margins and the quiet zone advice.
Event ticket HTML template
A complete template with a code sized in absolute units and its quiet zone in place.
Paste the markup into the playground with your own encoder's output and see what comes out at the real page size.