POSTNET

POSTNET barcode in PHP: ZIP code input, check digit, code examples and SVG output

POSTNET encodes a ZIP code in bar height rather than bar width: five bars per digit, two of them tall. It carried the ZIP, the ZIP+4 or the eleven-digit delivery point code, and the United States Postal Service retired it in favour of the Intelligent Mail Barcode.

Type Token

ItemValue
Type tokenPOSTNET
Enum caseBarcodeType::POSTNET
FamilyPostal
StandardUSPS-B-3200
Class\Com\Tecnick\Barcode\Type\Linear\Postnet

Input

ItemValue
Character setdigits
Length5, 9 or 11 digits in practice; the library accepts any number of them
Checkmodulo 10, appended by the library
Extra parametersnone

Examples

A ZIP+4 code

<?php

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

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

echo $bobj->getInlineSvgCode();

POSTNET barcode encoding 123456789

An eleven-digit delivery point code

$bobj = $barcode->getBarcodeObj(
    type: 'POSTNET',
    code: '12345678901',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

POSTNET barcode encoding 12345678901

Errors

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

PayloadMessage
1234AInvalid character: 65

See Also