Aspose.Barcode for Python via Java Generation and Recognition API docs

BarcodeGenerator for backend barcode images generation. More...

Inherits BaseJavaClass.

Public Member Functions

def __init__ (self, encodeType, Optional[str] codeText)
 BarcodeGenerator constructor. More...
 
str __str__ (self)
 
bool exportToXml (self, str filePath)
 Exports BarCode properties to the xml-stream specified. More...
 
Image generateBarCodeImage (self)
 Generate the barcode image under current settings. More...
 
EncodeTypes getBarcodeType (self)
 Barcode symbology type. More...
 
str getCodeText (self)
 Text to be encoded. More...
 
BaseGenerationParameters getParameters (self)
 Generation parameters. More...
 
None init (self)
 
None save (self, str imagePath, BarCodeImageFormat imageFormat)
 Save barcode image to specific file in specific format. More...
 
None setBarcodeType (self, EncodeTypes encodeType)
 Barcode symbology type. More...
 
None setCodeText (self, Union[str, bytes] value, Optional[str] encoding)
 
- Public Member Functions inherited from BaseJavaClass
None __init__ (self, javaClass)
 
def getJavaClass (self)
 
str getJavaClassName (self)
 
bool isNull (self)
 
None printJavaClassName (self)
 
None setJavaClass (self, javaClass)
 

Static Public Member Functions

BarcodeGenerator construct (javaClass)
 
BarcodeGenerator importFromXml (str resource)
 Imports BarCode properties from the xml-file specified and creates BarcodeGenerator instance. More...
 
str loadFileBase64String (str filepath)
 
str loadTextFileBase64String (str filepath)
 

Public Attributes

 javaClass
 
 parameters
 
- Public Attributes inherited from BaseJavaClass
 javaClass
 
 javaClassName
 

Static Public Attributes

string javaClassName = 'com.aspose.mw.barcode.generation.MwBarcodeGenerator'
 

Detailed Description

BarcodeGenerator for backend barcode images generation.

Supported symbologies:

1D: Codabar, Code11, Code128, Code39Standard, Code39Extended Code93Standard, Code93Extended, EAN13, EAN8, Interleaved2of5, MSI, Standard2of5, UPCA, UPCE, ISBN, GS1Code128, Postnet, Planet EAN14, SCC14, SSCC18, ITF14, SingaporePost ...

2D: Aztec, DataMatrix, PDf417, QR code ...

This sample shows how to create and save a barcode image.

encode_type = Generation.EncodeTypes.CODE_128
generator = Generation.BarcodeGenerator(encode_type, None)
generator.setCodeText("123ABCDFVC", "UTF-8")
generator.save(self.image_path_to_save1,Generation.BarCodeImageFormat.PNG)

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  encodeType,
Optional[str]  codeText 
)

BarcodeGenerator constructor.

Parameters
argsmay take the following combinations of arguments: 1) Barcode symbology type. Use EncodeTypes class to setup a symbology 2) type EncodeTypes, Text to be encoded.
barcodeGenerator = BarcodeGenerator(EncodeTypes.EAN_14, "332211")
Exceptions
BarCodeException

Member Function Documentation

◆ __str__()

str __str__ (   self)
Returns a string representation of the BarcodeGenerator object, showing key information.

◆ construct()

BarcodeGenerator construct (   javaClass)
static

◆ exportToXml()

bool exportToXml (   self,
str  filePath 
)

Exports BarCode properties to the xml-stream specified.

Parameters
filePathThe path to the file where the XML will be saved.
Returns
: Whether the export completed successfully. Returns True in case of success; False Otherwise.

◆ generateBarCodeImage()

Image generateBarCodeImage (   self)

Generate the barcode image under current settings.

This sample shows how to create and save a barcode image.

generator = Generation.BarcodeGenerator(Generation.EncodeTypes.CODE_128,"123ABCDEFG")
pillowImage = generator.generateBarCodeImage()
pillowImage.save(self.image_path_to_save)
@return: Pillow Image object of barcode image

◆ getBarcodeType()

EncodeTypes getBarcodeType (   self)

Barcode symbology type.

◆ getCodeText()

str getCodeText (   self)

Text to be encoded.

◆ getParameters()

BaseGenerationParameters getParameters (   self)

◆ importFromXml()

BarcodeGenerator importFromXml ( str  resource)
static

Imports BarCode properties from the xml-file specified and creates BarcodeGenerator instance.

Parameters
resource: The name of the file
Returns
: instance

◆ init()

None init (   self)

Reimplemented from BaseJavaClass.

◆ loadFileBase64String()

str loadFileBase64String ( str  filepath)
static
Converts a file to a base64-encoded string.

◆ loadTextFileBase64String()

str loadTextFileBase64String ( str  filepath)
static

◆ save()

None save (   self,
str  imagePath,
BarCodeImageFormat  imageFormat 
)

Save barcode image to specific file in specific format.

Parameters
imagePathPath to save to.
imageFormatOptional format override. If omitted, the format to use is determined from the filename extension. If a file object was used instead of a filename, this parameter should always be used.
generator = Generation.BarcodeGenerator(Generation.EncodeTypes.CODE_128, "123ABCDEFG")
generator.save(self.image_path_to_save3, Generation.BarCodeImageFormat.PNG)

◆ setBarcodeType()

None setBarcodeType (   self,
EncodeTypes  encodeType 
)

Barcode symbology type.

◆ setCodeText()

None setCodeText (   self,
Union[str, bytes]  value,
Optional[str]  encoding 
)
Encodes codetext with a byte order mark (BOM) using the specified encoding.
@param value: The CodeText string or bytes.
              If a bytes object is provided, it will be encoded to Base64.
@param encoding: The encoding to apply when processing the string value.

If 'value' is a bytes object, it is encoded using Base64.
If 'value' is a string, it's passed to 'setCodeText' of the Java class along with the specified encoding.

Member Data Documentation

◆ javaClass

javaClass

◆ javaClassName

string javaClassName = 'com.aspose.mw.barcode.generation.MwBarcodeGenerator'
static

◆ parameters

parameters