Japan Post

Japan Post customer barcode in PHP: postal code and address input, check character, code example and SVG output

Japan Post’s customer barcode carries the seven-digit postal code followed by the part of the address that identifies the delivery point. Bars take three shapes, and the alphabetic parts of an address are encoded through control characters, which is why the drawn symbol is longer than the text suggests.

Type Token

ItemValue
Type tokenJPPOST
Enum caseBarcodeType::JPPOST
FamilyPostal
Class\Com\Tecnick\Barcode\Type\Linear\JapanPost

Input

ItemValue
Character set0-9, A-Z and -
Lengtha 7 digit postal code, then up to 13 characters of address
Checkmodulo 19, appended by the library
Extra parametersnone

Examples

A postal code and address

<?php

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

$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
    type: 'JPPOST',
    code: '910-00673-80-25J1-2B',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

echo $bobj->getInlineSvgCode();

Japan Post barcode encoding 910-00673-80-25J1-2B

Errors

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

PayloadMessage
910The code must start with the 7 digit postal code
910-00673!Invalid character: 33

See Also