Browse our Products

Aspose.BarCode for Java 26.4 Release Notes

All Changes

KeySummaryCategory
BARCODENET-37745Reading barcodes from PDF - barcode is not recognizedBug
BARCODENET-38384Recognition of EAN barcodes while barcode read type is set to UPCBug
BARCODENET-38386Reader detects fragments of Code39Extended instead of VINBug
BARCODENET-38387Add option to BarCodeReader to recognize only required barcode typesEnhancement

Public API changes and New Features

OnlyRequestedTypes property for strict barcode type filtering

Methods setOnlyRequestedTypes(boolean) and isOnlyRequestedTypes():boolean have been added to the com.aspose.barcode.barcoderecognition.BarcodeSettings class.

When enabled, com.aspose.barcode.barcoderecognitionBarCodeReader returns only the barcode types explicitly specified in the decoding settings. Compatible or equivalent barcode types are excluded from the results, even if they can be successfully recognized.

When disabled, compatible and equivalent barcode types may be returned according to internal type mapping. For example, EAN-13 may also be returned when UPC-A is specified as the decoding type.

public void example() throws IOException {
    BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.EAN_13, "2383823482894");
    generator.save(folder + "test.png");

    // recognize only UPCA barcodes (no results, because source is EAN13)
    BarCodeReader reader1 = new BarCodeReader(folder + "test.png", DecodeType.UPCA);
    {
        reader1.getBarcodeSettings().setOnlyRequestedTypes(true);
        BarCodeResult[] barCodeResults1 = reader1.readBarCodes();

        if (barCodeResults1.length == 0) {
            System.out.println("No barcodes found (OnlyRequestedTypes = true)");
        }

        for (BarCodeResult result : barCodeResults1) {
            System.out.println("BarCode CodeText: " + result.getCodeText());
        }
    }
    //recognize compatible types: EAN13, UPCA, ISSN, ISMN, ISBN (EAN13 will be returned as UPCA-equivalent)
    BarCodeReader reader2 = new BarCodeReader(folder + "test.png", DecodeType.UPCA);
    {
        reader2.getBarcodeSettings().setOnlyRequestedTypes(false);
        BarCodeResult[] barCodeResults2 = reader2.readBarCodes();

        if (barCodeResults2.length == 0) {
            System.out.println("No barcodes found (OnlyRequestedTypes = false)");
        }

        for (BarCodeResult result : barCodeResults2) {
            System.out.println("BarCode CodeText: " + result.getCodeText());
        }
    }
}