Open samymassoud opened 3 years ago
Hi Samy,
Could you provide the code you use to generate the barcode?
Note that UPC-E is only valid with 6-digits. It will add a zero in front and a checksum in the end to create a valid UPC-E barcode. If you provide 8 digits, it will try to create an EAN-8 code as it is almost the same structure but valid with 8 digits.
If you have arbitrary lengths, then don't use UPC-E but the general purpose Code128
Hi Casper,
When I try 6 digits barcode it is not readable on any software scanner.
Here is an example.
Other alternatives will not allow less than 7 digits for the UPC-E
So tried the same, but still can't be scanned!
Same code on another alternative which can be scanned correctly!
Please provide the code you use to generate the barcode with this library, otherwise I have no place to start testing.
Sure
$generator = new BarcodeGeneratorPNG();
$color = [0,0,0];
$code = "0123456";
$img_str = $generator->getBarcode($code, $generator::TYPE_UPC_E,2, 90, $color);
echo '<img src="data:image/png;base64,' . base64_encode($img_str). '">';
Has there been any movement or solutions on this. I am finding increasing numbers of UPC_E barcodes out in the wild and we currently are unable to create scannable barcodes for them.
Here is what we are currently doing. Note that I am currently hardcoding the 6 digit upc in. It is a real upc for Mountain Dew that is 01213405 and we are hardcoding in 121340 to be processed by the barcode generator and spit out a UPC_E. `
$value = "01213405";
if (strlen($value) == 8) {
$value = substr($value, 1, 6);
$height = 72;
// hardcoding upc string for now
$svgData = $generator->getBarcode("121340", $generator::TYPE_UPC_E, 2, $height);
}
` This creates a barcode represented by this image: This appears to be a UPC style barcode given that it has the 4 different sized bars but is not scannable by barcode apps and does not look like like the barcode that exists for that given 6 digit code, represented by this image which was gotten by putting in "0121340" into this website. This is the correct barcode and matches the one on the side of the actual packaging. Trying to code it using EAN_8 does create a scannable barcode, but the barcode does not have the correct check value at the end (it creates it with a 9 for the check value). Passing the full 8 digit barcode using an EAN_8 type gives a "InvalidCheckDigitException" likely because for an EAN_8 to encode properly, it needs to be a 9.
We are currently running this in version 2.0.0
I figured out that the implemented UPC-E barcode is only working with UPC-A codes as input (properly converting them into UPC-E), but not with proper UPC-E codes as input. I started working on a solution for this issue.
@casperbakker , @samymassoud , @oitowl7
I've provided a pull request for this issue. Once merged into the main branch, it should fix all your problems. Please, let me know if you have still problems with barcode type UPC-E.
Was trying to generate the UPC-E for the following number 12345687
The output image of the library as follows:
Which will read as 01891113 on the scanner While the correct one is:
Something with the conversion to UPC-A and back to UPC-E must be wrong!
BTW: This nice library is part of the Online barcode generator , so thanks for the great effort.