Aspose.Barcode for PHP via Java Generation and Recognition API docs
ChecksumValidation Class Reference

Public Attributes

const DEFAULT = 0
 
const ON = 1
 
const OFF = 2
 

Detailed Description

Enable checksum validation during recognition for 1D barcodes. Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. Checksum never used: Codabar Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN Checksum always used: Rest symbologies

This sample shows influence of ChecksumValidation on recognition quality and results

$generator = new BarcodeGenerator(EncodeTypes::EAN_13, "1234567890128");
$generator->save("test.png", BarcodeImageFormat::PNG);
$reader = new BarCodeReader("test.png", null, DecodeType::EAN_13);
//checksum disabled
$reader->setChecksumValidation(ChecksumValidation::OFF);
foreach($reader->readBarCodes() as $result)
{
print("BarCode CodeText: ".$result->getCodeText());
print("BarCode Value: ".$result->getExtended()->getOneD()->getValue());
print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum());
}
$reader = new BarCodeReader("test.png", null, DecodeType::EAN_13);
//checksum enabled
$reader->setChecksumValidation(ChecksumValidation::ON);
foreach($reader->readBarCodes() as $result)
{
print("BarCode CodeText: ".$result->getCodeText());
print("BarCode Value: ".$result->getExtended()->getOneD()->getValue());
print("BarCode Checksum: ".$result->getExtended()->getOneD()->getCheckSum());
}

Member Data Documentation

◆ DEFAULT

const ChecksumValidation::DEFAULT = 0

If checksum is required by the specification - it will be validated.

◆ OFF

const ChecksumValidation::OFF = 2

Do not validate checksum.

◆ ON

const ChecksumValidation::ON = 1

Always validate checksum if possible.