Skip to content

Failed barcodes using CODE 128 with letters. #215

@jxr-koda

Description

@jxr-koda

I'm having a bit of trouble generating Code 128 B barcodes and I'm fairly lost as to why. I've written a short script that demonstrates the problem.

require 'vendor/autoload.php';

$code = '1GVRM3I09Z56';

//OLD Method
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
$barcode = $generator->getBarcode($code, $generator::TYPE_CODE_128);
file_put_contents('goodbarcode.png', $barcode);

//NEW Method
$barcode = (new \Picqer\Barcode\Types\TypeCode128())->getBarcode($code);
$barcodeRenderer = new \Picqer\Barcode\Renderers\PngRenderer();
file_put_contents('failedbarcode.png', $barcodeRenderer->render($barcode));

The old method generates a working barcode that scans correctly. Here's the file it generated:

Image

And the newer method, assuming I'm doing it correct, generates a barcode that can't be scanned:

Image

Any idea what's going on?

Note: when I only use numbers in $code, there are no issues. I tried forcing TypeCode128B() but this did not resolve the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions