The thirteen-digit article number printed on retail packaging almost everywhere outside North America. The first digits are the GS1 company prefix, issued by a GS1 member organisation; the last is a modulo 10 check digit.
Give the library twelve digits and it computes the check. Give it thirteen and it verifies the one you supplied, rather than appending a second.
Type Token
| Item | Value |
|---|---|
| Type token | EAN13 |
| Enum case | BarcodeType::EAN13 |
| Family | Linear |
| Standard | ISO/IEC 15420, GS1 General Specifications |
| Class | \Com\Tecnick\Barcode\Type\Linear\EanOneThree |
Input
| Item | Value |
|---|---|
| Character set | digits, plus + to introduce an add-on |
| Length | 12 digits, or 13 with a valid check digit |
| Check | modulo 10, appended when the payload is 12 digits and verified when it is 13 |
| Extra parameters | none |
Examples
An article number
<?php
require_once __DIR__ . '/vendor/autoload.php';
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
type: 'EAN13',
code: '9781234567897',
width: -3,
height: -30,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
echo $bobj->getInlineSvgCode();
With a five-digit add-on
$bobj = $barcode->getBarcodeObj(
type: 'EAN13',
code: '9781234567897+12345',
width: -3,
height: -30,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
Errors
These payloads raise \Com\Tecnick\Barcode\Exception:
| Payload | Message |
|---|---|
12345678901A | Input code must be a number |
0123456789013 | Invalid check digit: 2 |
9781234567897+123 | The add-on must be 2 or 5 digits: 123 |
See Also
- tc-lib-barcode : the library overview.
- Rendering Options : size, colour, padding.
- Output Formats : every renderer.
- EAN-8 : the short form for small packages.
- UPC-A : the North American twelve-digit form.
- EAN 5-digit add-on : the add-on symbol on its own.
- API reference : the generated class documentation.