EAN 2-digit add-on

EAN-2 add-on barcode in PHP: 2 digit input, code example and SVG output

A two-digit supplement, printed to the right of an EAN or UPC symbol and used for the issue number of a magazine or a periodical. It has no meaning on its own, and this type draws it on its own; to attach it to a main symbol, append it to the payload after a +.

Type Token

ItemValue
Type tokenEAN2
Enum caseBarcodeType::EAN2
FamilyLinear
StandardGS1 General Specifications
Class\Com\Tecnick\Barcode\Type\Linear\EanTwo

Input

ItemValue
Character setdigits
Length1 or 2 digits
Checknone; the parity pattern of the two digits carries the check
Extra parametersnone

Examples

An issue number

<?php

require_once __DIR__ . '/vendor/autoload.php';

$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
    type: 'EAN2',
    code: '12',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

echo $bobj->getInlineSvgCode();

EAN 2-digit add-on barcode encoding 12

Errors

These payloads raise \Com\Tecnick\Barcode\Exception:

PayloadMessage
123The code is too long: 3 digits (maximum 2 for EAN2)
abInput code must be a number

See Also