Square Raw Mode

Raw two-dimensional barcode rendering in PHP: module grid input, code example and SVG output

This is a custom format rather than a published symbology, the two-dimensional counterpart of LRAW. It allows a module grid computed elsewhere to be drawn as it is: rows of 0 and 1 separated by commas, one character per module, every row the same length.

Type Token

ItemValue
Type tokenSRAW
Enum caseBarcodeType::SRAW
Family2D
Class\Com\Tecnick\Barcode\Type\Square\Raw

Input

ItemValue
Character set0 and 1, with , separating the rows
Lengthany grid whose rows are all the same length
Checknone
Extra parametersnone

Examples

A four by four grid

<?php

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

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

echo $bobj->getInlineSvgCode();

Square Raw Mode barcode encoding 0101,1010,1100,0011

Errors

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

PayloadMessage
0101,10All the rows must have the same length: row 1 has 2 columns instead of 4
12The rows must only contain the characters 0 and 1: row 0 is “12”

See Also