BarcodeGenerator

Inheritance: java.lang.Object

public final class BarcodeGenerator

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.
  
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.CODE_128);
         generator.setCodeText("123ABC");
         generator.save("code128.png");

Constructors

ConstructorDescription
BarcodeGenerator(BaseEncodeType type)Creates an instance of BarcodeGenerator.
BarcodeGenerator(BaseEncodeType type, String codeText)Creates an instance of BarcodeGenerator.

Methods

MethodDescription
dispose()Clean up any resources being used.
equals(Object arg0)
exportToXml(OutputStream xml)Exports BarCode properties to the xml-stream specified
exportToXml(String xmlFile)Exports BarCode properties to the xml-file specified
generateBarCodeImage()Generate the barcode image under current settings.
getBarcodeType()Barcode symbology type.
getClass()
getCodeText()Text to be encoded.
getParameters()Generation parameters.
hashCode()
importFromXml(InputStream xml)Imports BarCode properties from the xml-stream specified and creates BarcodeGenerator instance.
importFromXml(String xmlFile)Imports BarCode properties from the xml-file specified and creates BarcodeGenerator instance.
notify()
notifyAll()
save(OutputStream stream, BarCodeImageFormat format)Save BarCodeImage to stream in specific format.
save(String filename)Save barcode image to specific file.
save(String filename, BarCodeImageFormat format)Save barcode image to specific file in specific format.
setBarcodeType(BaseEncodeType value)Barcode symbology type.
setCodeText(byte[] codeBytes)Set codetext as sequence of bytes.
setCodeText(String value)Text to be encoded.
setCodeText(String codeText, Charset encoding)Encodes codetext with byte order mark (BOM) using specified encoding.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

BarcodeGenerator(BaseEncodeType type)

public BarcodeGenerator(BaseEncodeType type)

Creates an instance of BarcodeGenerator.

Parameters:

ParameterTypeDescription
typeBaseEncodeTypeBarcode symbology type. Use EncodeTypes class to setup a symbology.

BarcodeGenerator(BaseEncodeType type, String codeText)

public BarcodeGenerator(BaseEncodeType type, String codeText)

Creates an instance of BarcodeGenerator.

Parameters:

ParameterTypeDescription
typeBaseEncodeTypeBarcode symbology type. Use EncodeTypes class to setup a symbology.
codeTextjava.lang.StringText to be encoded.

dispose()

public void dispose()

Clean up any resources being used.

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

exportToXml(OutputStream xml)

public boolean exportToXml(OutputStream xml)

Exports BarCode properties to the xml-stream specified

Parameters:

ParameterTypeDescription
xmljava.io.OutputStreamThe xml-stream

Returns: boolean - Whether or not export completed successfully. Returns True in case of success; False Otherwise

exportToXml(String xmlFile)

public boolean exportToXml(String xmlFile)

Exports BarCode properties to the xml-file specified

Parameters:

ParameterTypeDescription
xmlFilejava.lang.StringThe name of the file

Returns: boolean - Whether or not export completed successfully.

Returns True in case of success; False Otherwise

generateBarCodeImage()

public Bitmap generateBarCodeImage()

Generate the barcode image under current settings.


This sample shows how to create and save a barcode image.
  
         BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.CODE_128);
         File outputFile = new File("test.png");
         OutputStream os = new FileOutputStream(outputFile);
         Bitmap generatedBitmap = generator.generateBarCodeImage();
         generatedBitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
         os.flush();
         os.close();

Returns: android.graphics.Bitmap - Barcode image. See Bitmap .

getBarcodeType()

public BaseEncodeType getBarcodeType()

Barcode symbology type.

Returns: BaseEncodeType

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getCodeText()

public String getCodeText()

Text to be encoded.

Returns: java.lang.String

getParameters()

public BaseGenerationParameters getParameters()

Generation parameters.

Returns: BaseGenerationParameters

hashCode()

public native int hashCode()

Returns: int

importFromXml(InputStream xml)

public static BarcodeGenerator importFromXml(InputStream xml)

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

Parameters:

ParameterTypeDescription
xmljava.io.InputStreamThe xml-stream

Returns: BarcodeGenerator - BarcodeGenerator instance

importFromXml(String xmlFile)

public static BarcodeGenerator importFromXml(String xmlFile)

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

Parameters:

ParameterTypeDescription
xmlFilejava.lang.StringThe name of the file

Returns: BarcodeGenerator - BarcodeGenerator instance

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

save(OutputStream stream, BarCodeImageFormat format)

public void save(OutputStream stream, BarCodeImageFormat format)

Save BarCodeImage to stream in specific format.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStream
formatBarCodeImageFormat

save(String filename)

public void save(String filename)

Save barcode image to specific file.

Parameters:

ParameterTypeDescription
filenamejava.lang.StringPath to save to.

save(String filename, BarCodeImageFormat format)

public void save(String filename, BarCodeImageFormat format)

Save barcode image to specific file in specific format.

Parameters:

ParameterTypeDescription
filenamejava.lang.StringPath to save to.
formatBarCodeImageFormatSpecifies the file format of the output image.

setBarcodeType(BaseEncodeType value)

public void setBarcodeType(BaseEncodeType value)

Barcode symbology type.

Parameters:

ParameterTypeDescription
valueBaseEncodeType

setCodeText(byte[] codeBytes)

public void setCodeText(byte[] codeBytes)

Set codetext as sequence of bytes.

Parameters:

ParameterTypeDescription
codeBytesbyte[]Bytes of codetext

setCodeText(String value)

public void setCodeText(String value)

Text to be encoded.

Parameters:

ParameterTypeDescription
valuejava.lang.String

setCodeText(String codeText, Charset encoding)

public void setCodeText(String codeText, Charset encoding)

Encodes codetext with byte order mark (BOM) using specified encoding.

Parameters:

ParameterTypeDescription
codeTextjava.lang.StringCodeText string
encodingjava.nio.charset.CharsetApplied encoding

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int