php-barcode-generator icon indicating copy to clipboard operation
php-barcode-generator copied to clipboard

Failed barcodes using CODE 128 with letters.

Open jxr-koda opened this issue 8 months ago • 0 comments

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.

jxr-koda avatar Apr 02 '25 18:04 jxr-koda