PDFPipe

Linear (1D) / EAN-8

EAN-8 barcode in a PDF

The short retail barcode for packs too small to carry EAN-13: eight digits, a symmetric quiet zone, and a number you have to be granted rather than derive.

Where the symbol comes from

This API renders HTML to PDF. It does not generate barcodes, so the EAN-8 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

Exactly eight digits. Seven are data, made up of a GS1-8 prefix and an item reference, and the eighth is a check digit. There is no company prefix embedded the way there is in EAN-13, which is precisely why it has to be allocated centrally: the number carries no structure a manufacturer could allocate from.

The check digit, and who computes it

The eighth digit, modulo 10, with weights alternating 3 and 1 starting from the leftmost digit. Note the starting weight differs from EAN-13, where the alternation begins with 1 because the number has an odd length. Copying an EAN-13 check routine and feeding it eight digits produces a wrong digit that looks plausible.

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.330mm at 100 percent magnification, giving a nominal symbol of 26.73 by 21.64mm. The permitted magnification range is the same 80 to 200 percent as EAN-13, so the X-dimension can fall to 0.264mm. There is no smaller retail option below this: EAN-8 already is the small option.
  • Quiet zone: 7 times the X-dimension at both ends, and symmetric, which is the difference worth carrying away from this page. EAN-13 has an asymmetric quiet zone with a wider left margin. A designer who learned the EAN-13 figure and applies it here wastes space on a pack that had none to spare.

Where it is used

  • confectionery, chewing gum and single-serve items where a full EAN-13 will not physically fit
  • cosmetics and small toiletries
  • tobacco packaging
  • any retail item where the printable panel is smaller than about 40mm across

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.

html
<!-- EAN-8 is allocated on application, not derived from an EAN-13.
     There is no algorithm that shortens your existing number. -->
<figure class="ean8">
  <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0i..." alt="EAN-8 96385074">
</figure>

<style>
.ean8 {
  margin: 0;
  /* 7X either side at 100 percent magnification is 2.31mm. Rounded up to
     2.5mm, symmetric, because EAN-8 has no wide side. */
  padding: 0 2.5mm;
  background: #fff;
  width: max-content;
  print-color-adjust: exact;
  -webkit-print-color-adjust: exact;
}
.ean8 img {
  /* Nominal size at 100 percent. The digits are part of the encoder's
     output here rather than a caption, because their position and font
     are specified for retail symbols. */
  width: 26.73mm;
  height: 21.64mm;
  display: block;
}
</style>

What goes wrong on paper

Letting the pack artwork crowd it. EAN-8 exists because the panel is small, so it is the symbology most likely to sit next to something, and 2.31mm of white at 100 percent magnification is easy to lose to a border rule or an ingredients panel. Reserve the quiet zone as padding on the container rather than trusting the encoder to include it in the image.

First thing to check when it will not scan

Confirm it really is an EAN-8 and not an EAN-13 with five digits removed. That does not work, produces eight digits that pass a casual look, and fails the check digit. If the number came from a spreadsheet rather than from a GS1 allocation, that is the first thing to prove.

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 EAN-8 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.330mm at 100 percent magnification, giving a nominal symbol of 26.73 by 21.64mm. The permitted magnification range is the same 80 to 200 percent as EAN-13, so the X-dimension can fall to 0.264mm. There is no smaller retail option below this: EAN-8 already is the small option. 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.

Paste the markup into the playground with your own encoder's output and see what comes out at the real page size.