Aztec Code

Aztec Code in PHP: error correction percentage, encoding hints, code examples and SVG output

Aztec puts its finder in the middle, a bullseye of concentric squares, and grows outward in layers. There is no quiet zone requirement, which is why transport operators print it on tickets and boarding passes where every millimetre is spoken for.

Error correction is a percentage, not a level. The library defaults to 33 per cent of the symbol and accepts anything from 1 to 100; the standard sets the floor at 23 per cent plus three codewords.

Type Token

ItemValue
Type tokenAZTEC
Enum caseBarcodeType::AZTEC
Family2D
StandardISO/IEC 24778
Class\Com\Tecnick\Barcode\Type\Square\Aztec

Input

ItemValue
Character setany byte sequence
Lengthup to 3832 digits or 3067 letters in a full range symbol
CheckReed-Solomon error correction at the chosen percentage
Extra parameters4 (see below)

Extra Parameters

Appended to the type token after commas, as in AZTEC,50,A,A.

PositionMeaningValuesDefault
1error correction percentage1 to 10033
2encoding hintA automatic, B binaryA
3symbol rangeA automatic, F full rangeA
4ECI codean ECI identifier for the character setunset

Examples

Mixed letters and digits

<?php

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

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

echo $bobj->getInlineSvgCode();

Aztec Code barcode encoding ABCDabcd01234

Half the symbol given over to error correction

$bobj = $barcode->getBarcodeObj(
    type: 'AZTEC,50,A,A',
    code: 'ABCDabcd01234',
    width: -4,
    height: -4,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

Aztec Code barcode encoding ABCDabcd01234

Errors

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

PayloadMessage
``Empty input

See Also