Browse our Products

Aspose.BarCode for Python via Java 24.9

All Changes

KeySummaryCategory
BARCODENET-38022AustralianPostShortBarHeight is ignoredBug + Enhancement
BARCODENET-38369Update PZN encoder, decoderEnhancement
BARCODENET-39081Add tests for functionality that was added in release 24.6 including setters and gettersQuality issue
BARCODENET-39089Recognize and add QrVersion to QRExtendedParameters in BarCodeResultEnhancement

Public API changes and backwards compatibility

AustraliaPost, Planet, Postnet barcodes generation

AustraliaPost, Planet, Postnet barcodes generation is changed.

AustralianPost.AustralianPostShortBarHeight by default is set to zero and calculated by default as 0.26 from BarHeight.

from asposebarcode.Generation import EncodeTypes,CustomerInformationInterpretingType,BarCodeImageFormat,BarcodeGenerator,CodeLocation,QRVersion,QRErrorLevel
from asposebarcode.Recognition import BarCodeReader,DecodeType
#AustraliaPost barcode generation
def testExample1(self):
    gen = BarcodeGenerator(EncodeTypes.AUSTRALIA_POST, "6212345678AP")
    gen.getParameters().getBarcode().getAustralianPost().setAustralianPostEncodingTable(CustomerInformationInterpretingType.C_TABLE)
    gen.getParameters().getBarcode().getBarHeight().setPixels(100)
    gen.save(self.image_path_to_save1, BarCodeImageFormat.PNG)

# If short bar is not specified, it is scaled to 0.26 * BarHeight
def testExample2(self):
    gen = BarcodeGenerator(EncodeTypes.AUSTRALIA_POST, "6212345678AP")
    gen.getParameters().getBarcode().getAustralianPost().getAustralianPostShortBarHeight().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getLeft().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getTop().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getRight().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getBottom().setPixels(10)
    gen.save(self.image_path_to_save2, BarCodeImageFormat.PNG)

Postal.PostalShortBarHeight by default is set to zero and calculated by default as 0.5 from BarHeight.

#Planet, Postnet barcodes generation
def testExample3(self):
    gen = BarcodeGenerator(EncodeTypes.POSTNET, "5552357000")
    gen.getParameters().getBarcode().getBarHeight().setPixels(100)
    #If short bar is not specified, it is scaled to 0.5 * BarHeight
    gen.getParameters().getBarcode().getPostal().getPostalShortBarHeight().setPixels(40)
    gen.getParameters().getBarcode().getCodeTextParameters().setLocation(CodeLocation.NONE)
    gen.getParameters().getBarcode().getPadding().getLeft().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getTop().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getRight().setPixels(10)
    gen.getParameters().getBarcode().getPadding().getBottom().setPixels(10)
    gen.save(self.image_path_to_save3, BarCodeImageFormat.PNG)

PZN7 and PZN8 barcodes generation

PZN8 and PZN7 encoding and decoding are supported:

  • To encode PZN7 it is needed to provide 6 digits or less to CodeText, like “123456”.
  • To encode PZN8 it is needed to provide 7 digits or more to CodeText, like “1234567”.
  • Provided last checksum digit is ignored and generated by the barcode engine.
# Encode and decode PZN7
# When you provide a 6-digit code text to the BarcodeGenerator with EncodeTypes.PZN, 
# the library interprets it as a PZN7 barcode. 
# The PZN7 format consists of 7 digits: 6 data digits plus 1 check digit calculated by the system.
def testExample4(self):
    gen = BarcodeGenerator(EncodeTypes.PZN, "123456")
    reader = BarCodeReader(gen.generateBarCodeImage(), None, DecodeType.PZN)
    results = reader.readBarCodes()
    for result in results:
        print(f"\nBarCode Type: {result.getCodeTypeName()}")
        print(f"BarCode CodeText: {result.getCodeText()}")

#Encode and decode PZN8
#When you provide a 7-digit code text, the library generates a PZN8 barcode. 
# The PZN8 format consists of 8 digits: 7 data digits plus 1 check digit calculated by the system.
def testExample5(self):
    gen = BarcodeGenerator(EncodeTypes.PZN, "1234567")
    reader = BarCodeReader(gen.generateBarCodeImage(), None, DecodeType.PZN)
    results = reader.readBarCodes()
    for result in results:
        print(f"\nBarCode Type: {result.getCodeTypeName()}")
        print(f"BarCode CodeText: {result.getCodeText()}")

QR, MicroQR, RectMicroQR barcodes recognition

QR, MicroQR, RectMicroQR barcodes recognition parameters obtained new public properties QRVersion, MicroQRVersion, RectMicroQRVersion and QRErrorLevel, which have been added to the QRExtendedParameters.

def testExample6(self):
gen = BarcodeGenerator(EncodeTypes.QR, "Aspose")
gen.getParameters().getBarcode().getQR().setQrVersion(QRVersion.VERSION_15)
gen.getParameters().getBarcode().getQR().setQrErrorLevel(QRErrorLevel.LEVEL_M)
reader = BarCodeReader(gen.generateBarCodeImage(), None, DecodeType.QR)
results = reader.readBarCodes()
for result in results:
    print(f"\nCodetype: {result.getCodeTypeName()}")
    print(f"Codetext: {result.getCodeText()}")
    print(f"QR version:  {result.getExtended().getQR().getQRVersion()}")
    print(f"Error level:  {result.getExtended().getQR().getQRErrorLevel()}")

Result:

Codetype: QR
Codetext: Aspose
QR version: VERSION_15
Error level: LEVEL_M