Codabar

Codabar barcode in PHP: character set, start and stop characters, code example and SVG output

Codabar dates from 1972 and encodes digits and six punctuation marks, one character per four bars and three spaces.

Four letters, A to D, serve as the start and stop characters. The library brackets the payload with A at both ends and rejects those four letters inside it, since a scanner reading one mid-symbol would take it for the end of the code.

Type Token

ItemValue
Type tokenCODABAR
Enum caseBarcodeType::CODABAR
FamilyLinear
StandardUSS-Codabar, ANSI/AIM BC3
Class\Com\Tecnick\Barcode\Type\Linear\Codabar

Input

ItemValue
Character set0-9, -, $, :, /, ., +
Length1 to 30000 characters
Checknone
Extra parametersnone

Examples

Ten digits

<?php

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

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

echo $bobj->getInlineSvgCode();

Codabar barcode encoding 0123456789

Errors

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

PayloadMessage
A0123456789BThe characters A, B, C and D are reserved as start/stop characters
12*Invalid character: 42

See Also