PDF417

PDF417 barcode in PHP: aspect ratio, error correction levels, code examples and SVG output

PDF417 is stacked rather than matrix: rows of codewords, each 17 modules wide and made of four bars and four spaces, which is where the name comes from. Driving licences and boarding passes carry it because a linear scanner sweeping across the rows can read it.

An aspect ratio sets the shape, and the nine error correction levels run from 2 correctable codewords at level 0 to 512 at level 8.

Type Token

ItemValue
Type tokenPDF417
Enum caseBarcodeType::PDF417
Family2D
StandardISO/IEC 15438
Class\Com\Tecnick\Barcode\Type\Square\PdfFourOneSeven

Input

ItemValue
Character setany byte sequence
Lengthup to 2710 digits or 1850 text characters
CheckReed-Solomon error correction at the chosen level
Extra parameters3 (see below)

Extra Parameters

Appended to the type token after commas, as in PDF417,2,5.

PositionMeaningValuesDefault
1aspect ratioa number not less than 12
2error correction level0 to 8automatic
3macro block parameterssegment index, file id and optionsunset

Examples

Digits at the automatic error correction level

<?php

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

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

echo $bobj->getInlineSvgCode();

PDF417 barcode encoding 0123456789

Aspect ratio 4 at error correction level 2

$bobj = $barcode->getBarcodeObj(
    type: 'PDF417,4,2',
    code: 'tc-lib-barcode',
    width: -4,
    height: -4,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

PDF417 barcode encoding tc-lib-barcode

Errors

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

PayloadMessage
``Empty input

See Also