Interleaved 2 of 5

Interleaved 2 of 5 barcode in PHP: numeric input, even length padding, code example and SVG output

Interleaving is what makes this one compact: the first digit of each pair is drawn in the bars and the second in the spaces between them. A numeric payload comes out at roughly half the width of Standard 2 of 5.

The pairing means the digit count has to be even. The library prepends a zero when it is odd, so 012345678 and 0012345678 produce the same symbol.

Type Token

ItemValue
Type tokenI25
Enum caseBarcodeType::I25
FamilyLinear
StandardISO/IEC 16390
Class\Com\Tecnick\Barcode\Type\Linear\InterleavedTwoOfFive

Input

ItemValue
Character setdigits
Lengthany number of digits; an odd count is left-padded with a zero
Checknone. Use I25+ for the modulo 10 check digit
Extra parametersnone

Examples

Ten digits

<?php

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

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

echo $bobj->getInlineSvgCode();

Interleaved 2 of 5 barcode encoding 0123456789

Errors

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

PayloadMessage
12AInvalid character sequence: 2a

See Also