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
Constructor | Description |
---|---|
BarcodeGenerator(BaseEncodeType type) | Creates an instance of BarcodeGenerator. |
BarcodeGenerator(BaseEncodeType type, String codeText) | Creates an instance of BarcodeGenerator. |
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
type | BaseEncodeType | Barcode 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:
Parameter | Type | Description |
---|---|---|
type | BaseEncodeType | Barcode symbology type. Use EncodeTypes class to setup a symbology. |
codeText | java.lang.String | Text to be encoded. |
dispose()
public void dispose()
Clean up any resources being used.
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
exportToXml(OutputStream xml)
public boolean exportToXml(OutputStream xml)
Exports BarCode properties to the xml-stream specified
Parameters:
Parameter | Type | Description |
---|---|---|
xml | java.io.OutputStream | The 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:
Parameter | Type | Description |
---|---|---|
xmlFile | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
xml | java.io.InputStream | The 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:
Parameter | Type | Description |
---|---|---|
xmlFile | java.lang.String | The 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:
Parameter | Type | Description |
---|---|---|
stream | java.io.OutputStream | |
format | BarCodeImageFormat |
save(String filename)
public void save(String filename)
Save barcode image to specific file.
Parameters:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | Path 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:
Parameter | Type | Description |
---|---|---|
filename | java.lang.String | Path to save to. |
format | BarCodeImageFormat | Specifies the file format of the output image. |
setBarcodeType(BaseEncodeType value)
public void setBarcodeType(BaseEncodeType value)
Barcode symbology type.
Parameters:
Parameter | Type | Description |
---|---|---|
value | BaseEncodeType |
setCodeText(byte[] codeBytes)
public void setCodeText(byte[] codeBytes)
Set codetext as sequence of bytes.
Parameters:
Parameter | Type | Description |
---|---|---|
codeBytes | byte[] | Bytes of codetext |
setCodeText(String value)
public void setCodeText(String value)
Text to be encoded.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.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:
Parameter | Type | Description |
---|---|---|
codeText | java.lang.String | CodeText string |
encoding | java.nio.charset.Charset | Applied 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:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |