Novis\Image\Barcode::Symbology
The barcode format that Barcode::render and Barcode::svg draw. A barcode format is also called a symbology.
Barcode::Symbology is declared in the class Novis\Image\Barcode.
Each format takes different data. The data must already contain its check digit.
Code128takes any plain ASCII text, such as a tracking number.Gs1128takes GS1 element strings. Each one starts with its identifier in brackets, as in(01)09501101530003(10)ABC.Ean13takes the 13 digits printed on a product.Ean8takes 8 digits, for small products.UpcAtakes the 12 digits used on products in North America.Code39takes digits, capital letters, spaces and the characters- . $ / + %.Itf14takes the 14 digits printed on a shipping box.DataMatrixtakes any text and draws a square code.
The others draw lines of bars. Data that the format cannot contain throws a LogicError.
Examples
Every type and its data
<?nvs// Shows the data each `Barcode::Symbology` takes, and the size of the image it draws.use Novis\Image\Barcode;use Novis\Image\Image;
// Each row is a type and data that the type can hold.array<{ symbology: Barcode::Symbology, data: string }> $rows = [ { symbology: Barcode::Symbology::Code128, data: 'Shop-42' }, { symbology: Barcode::Symbology::Gs1128, data: '(01)09501101530003(10)ABC' }, { symbology: Barcode::Symbology::Ean13, data: '4006381333931' }, { symbology: Barcode::Symbology::Ean8, data: '96385074' }, { symbology: Barcode::Symbology::UpcA, data: '036000291452' }, { symbology: Barcode::Symbology::Code39, data: 'SHOP-42' }, { symbology: Barcode::Symbology::Itf14, data: '15400141288763' }, { symbology: Barcode::Symbology::DataMatrix, data: 'Shop order 1042' },];
// This prints the width and height of each image in pixels.// Only the `DataMatrix` image is square.foreach ($rows as var $row) { var $info = Image::info(Barcode::render($row->data, $row->symbology)); echo $row->data, ': ', $info->width, 'x', $info->height, "\n";}Shop-42: 264x120(01)09501101530003(10)ABC: 616x1204006381333931: 230x12096385074: 174x120036000291452: 230x120SHOP-42: 272x12015400141288763: 308x120Shop order 1042: 80x80