com.aspose.barcode
Class BarCodeReader

java.lang.Object
  extended bycom.aspose.barcode.BarCodeReader

public final class BarCodeReader
extends java.lang.Object

BarCodeReader encapsulates an image, it then perform Read operation to detect one or more barcodes on this image.

Example
 	public void paint(Graphics g)
 	{
 		try
 		{
 			Image img = this.getToolkit().getImage("c:\\test.jpg");
 			BarCodeReader reader = new BarCodeReader(img);
 			BarCodeInfo[] results = null;
 			results = reader.read();
 			if(results.length > 0)
 			{
 				g.drawString("barcode found:" + results[0].getCodeText(), 10, 10);
 			}
 			else
 			{
 				g.drawString("barcode not found", 10, 10);
 			}
 		} catch (Exception ex)
 		{
 			ex.printStackTrace();
 		}
 	}
 


Field Summary
static int ORIENTATION_EAST
          Specifies scanning direction from left to right
static int ORIENTATION_NORTH
          Specifies scanning direction from bottom to top
static int ORIENTATION_SOUTH
          Specifies scanning direction from top to bottom
static int ORIENTATION_WEST
          Specifies scanning direction from right to left
static long SYMBOLOGY_AZTEC
          Specifies Aztec type of barcode
static long SYMBOLOGY_CODABAR
          Specifies Codabar type of barcode
static long SYMBOLOGY_CODE11
          Specifies Code11 type of barcode
static long SYMBOLOGY_CODE39EXTENDED
          Specifies Code39 Extended type of barcode
static long SYMBOLOGY_CODE39STANDARD
          Specifies Code39 Standard type of barcode
static long SYMBOLOGY_CODE93EXTENDED
          Specifies Code93 Extended type of barcode
static long SYMBOLOGY_CODE93STANDARD
          Specifies Code93 Standardtype of barcode
static long SYMBOLOGY_DATAMATRIX
          Specifes Datamatrix type of barcode
static long SYMBOLOGY_EAN128
          Specifes Ean128 type of barcode
static long SYMBOLOGY_EAN13
          Specifies EAN13 type of barcode
static long SYMBOLOGY_EAN14
          Specifies EAN14 type of barcode
static long SYMBOLOGY_EAN8
          Specifies EAN8 type of barcode
static long SYMBOLOGY_INTERLEAVED2OF5
          Specifies Interleaved 2 of 5 type of barcode
static long SYMBOLOGY_ITF14
          Specifes ITF14 type of barcode
static long SYMBOLOGY_MACROPDF417
          Specifies PDF417 type of barcode
static long SYMBOLOGY_MSI
          Specifies MSI type of barcode
static long SYMBOLOGY_PDF417
          Specifies PDF417 type of barcode
static long SYMBOLOGY_PLANET
          Specifies Planet type of barcode
static long SYMBOLOGY_POSTNET
          Specifies Postnet type of barcode
static long SYMBOLOGY_QR
          Specifies QR type of barcode
static long SYMBOLOGY_SSCC18
          Specifies SSCC18 type of barcode
static long SYMBOLOGY_STANDARD2OF5
          Specifies Standard 2 of 5 type of barcode
static long SYMBOLOGY_UPCA
          Specifies UPCA type of barcode
static long SYMBOLOGY_UPCE
          Specifies UPCE type of barcode
 
Constructor Summary
BarCodeReader(java.awt.Image image)
          Instantiates x barcode reader to detect barcodes from the specified image
 
Method Summary
 boolean getDetectSupplement()
          Gets whether to detect supplement barcode for EAN13, EAN8, BooklandEAN, UPCA, UPCE barcode.
 int getOrientation()
          Sets the scan direction for BarCodeReader.
 int getScanStep()
          Gets how many pixels reader advances at one time.
 long getSymbology()
          Gets the symbology settings.
 boolean getVerifyChecksum()
          Gets whether verify the checksum of x detected barcode.
 BarCodeInfo[] read()
          

Scan the image for barcodes.

 void setDetectSupplement(boolean value)
          Sets whether to detect supplenent barcode for EAN13, EAN8, BooklandEAN, UPCA, UPCE barcode.
 void setImage(java.awt.Image value)
          Sets the image for reader to scan
 void setOrientation(int value)
          Sets the scan direction for BarCodeReader.
 void setScanStep(int value)
          Sets how many pixels reader advances at one time.
 void setSymbology(long value)
          

Sets the symbology for target barcode.

 void setVerifyChecksum(boolean value)
          Sets whether verify the checksum of x detected barcode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYMBOLOGY_CODABAR

public static final long SYMBOLOGY_CODABAR
Specifies Codabar type of barcode

See Also:
com.aspose.barcode.Symbology.CODABAR, Constant Field Values

SYMBOLOGY_CODE11

public static final long SYMBOLOGY_CODE11
Specifies Code11 type of barcode

See Also:
com.aspose.barcode.Symbology.CODE11, Constant Field Values

SYMBOLOGY_CODE39EXTENDED

public static final long SYMBOLOGY_CODE39EXTENDED
Specifies Code39 Extended type of barcode

See Also:
com.aspose.barcode.Symbology.CODE39EXTENDED, Constant Field Values

SYMBOLOGY_CODE39STANDARD

public static final long SYMBOLOGY_CODE39STANDARD
Specifies Code39 Standard type of barcode

See Also:
com.aspose.barcode.Symbology.CODE39STANDARD, Constant Field Values

SYMBOLOGY_CODE93EXTENDED

public static final long SYMBOLOGY_CODE93EXTENDED
Specifies Code93 Extended type of barcode

See Also:
com.aspose.barcode.Symbology.CODE93EXTENDED, Constant Field Values

SYMBOLOGY_CODE93STANDARD

public static final long SYMBOLOGY_CODE93STANDARD
Specifies Code93 Standardtype of barcode

See Also:
com.aspose.barcode.Symbology.CODE93STANDARD, Constant Field Values

SYMBOLOGY_EAN13

public static final long SYMBOLOGY_EAN13
Specifies EAN13 type of barcode

See Also:
com.aspose.barcode.Symbology.EAN13, Constant Field Values

SYMBOLOGY_EAN8

public static final long SYMBOLOGY_EAN8
Specifies EAN8 type of barcode

See Also:
com.aspose.barcode.Symbology.EAN8, Constant Field Values

SYMBOLOGY_INTERLEAVED2OF5

public static final long SYMBOLOGY_INTERLEAVED2OF5
Specifies Interleaved 2 of 5 type of barcode

See Also:
com.aspose.barcode.Symbology.INTERLEAVED2OF5, Constant Field Values

SYMBOLOGY_MSI

public static final long SYMBOLOGY_MSI
Specifies MSI type of barcode

See Also:
com.aspose.barcode.Symbology.MSI, Constant Field Values

SYMBOLOGY_STANDARD2OF5

public static final long SYMBOLOGY_STANDARD2OF5
Specifies Standard 2 of 5 type of barcode

See Also:
com.aspose.barcode.Symbology.STANDARD2OF5, Constant Field Values

SYMBOLOGY_UPCA

public static final long SYMBOLOGY_UPCA
Specifies UPCA type of barcode

See Also:
com.aspose.barcode.Symbology.UPCA, Constant Field Values

SYMBOLOGY_UPCE

public static final long SYMBOLOGY_UPCE
Specifies UPCE type of barcode

See Also:
com.aspose.barcode.Symbology.UPCE, Constant Field Values

SYMBOLOGY_EAN128

public static final long SYMBOLOGY_EAN128
Specifes Ean128 type of barcode

See Also:
com.aspose.barcode.Symbology.EAN128, Constant Field Values

SYMBOLOGY_PDF417

public static final long SYMBOLOGY_PDF417
Specifies PDF417 type of barcode

See Also:
com.aspose.barcode.Symbology.PDF417, Constant Field Values

SYMBOLOGY_MACROPDF417

public static final long SYMBOLOGY_MACROPDF417
Specifies PDF417 type of barcode

See Also:
com.aspose.barcode.Symbology.PDF417, Constant Field Values

SYMBOLOGY_DATAMATRIX

public static final long SYMBOLOGY_DATAMATRIX
Specifes Datamatrix type of barcode

See Also:
com.aspose.barcode.Symbology.DATAMATRIX, Constant Field Values

SYMBOLOGY_AZTEC

public static final long SYMBOLOGY_AZTEC
Specifies Aztec type of barcode

See Also:
com.aspose.barcode.Symbology.AZTEC, Constant Field Values

SYMBOLOGY_QR

public static final long SYMBOLOGY_QR
Specifies QR type of barcode

See Also:
com.aspose.barcode.Symbology.QR, Constant Field Values

SYMBOLOGY_ITF14

public static final long SYMBOLOGY_ITF14
Specifes ITF14 type of barcode

See Also:
com.aspose.barcode.Symbology.ITF14, Constant Field Values

SYMBOLOGY_EAN14

public static final long SYMBOLOGY_EAN14
Specifies EAN14 type of barcode

See Also:
com.aspose.barcode.Symbology.EAN14, Constant Field Values

SYMBOLOGY_SSCC18

public static final long SYMBOLOGY_SSCC18
Specifies SSCC18 type of barcode

See Also:
com.aspose.barcode.Symbology.SSCC18, Constant Field Values

SYMBOLOGY_PLANET

public static final long SYMBOLOGY_PLANET
Specifies Planet type of barcode

See Also:
com.aspose.barcode.Symbology.PLANET, Constant Field Values

SYMBOLOGY_POSTNET

public static final long SYMBOLOGY_POSTNET
Specifies Postnet type of barcode

See Also:
com.aspose.barcode.Symbology.POSTNET, Constant Field Values

ORIENTATION_EAST

public static final int ORIENTATION_EAST
Specifies scanning direction from left to right

See Also:
com.aspose.barcode.Orientation.East, Constant Field Values

ORIENTATION_WEST

public static final int ORIENTATION_WEST
Specifies scanning direction from right to left

See Also:
com.aspose.barcode.Orientation.West, Constant Field Values

ORIENTATION_SOUTH

public static final int ORIENTATION_SOUTH
Specifies scanning direction from top to bottom

See Also:
com.aspose.barcode.Orientation.South, Constant Field Values

ORIENTATION_NORTH

public static final int ORIENTATION_NORTH
Specifies scanning direction from bottom to top

See Also:
com.aspose.barcode.Orientation.North, Constant Field Values
Constructor Detail

BarCodeReader

public BarCodeReader(java.awt.Image image)
              throws java.lang.Exception
Instantiates x barcode reader to detect barcodes from the specified image

Parameters:
image - of Image
Throws:
java.lang.Exception - when image format not supported
Method Detail

getSymbology

public long getSymbology()
Gets the symbology settings.

Returns:
Symbology

setSymbology

public void setSymbology(long value)

Sets the symbology for target barcode. Assign -1 for all symbologies.

Example
 	public void paint(Graphics g)
 	{
 		try
 		{
 			Image img = this.getToolkit().getImage("c:\\test.jpg");
 			BarCodeReader reader = new BarCodeReader(img);
 			//Target barcode would be EAN13 or UPCA
 			reader.setSymbology(Symbology.EAN13 | Symbology.UPCA);
 			BarCodeInfo[] results = null;
 			results = reader.read();
 			if(results.length > 0)
 			{
 				g.drawString("barcode found:" + results[0].getCodeText(), 10, 10);
 			}
 			else
 			{
 				g.drawString("barcode not found", 10, 10);
 			}
 		} catch (Exception ex)
 		{
 			ex.printStackTrace();
 		}
 	}
 

Parameters:
value -
See Also:
Symbology

getVerifyChecksum

public boolean getVerifyChecksum()
Gets whether verify the checksum of x detected barcode. Wrong checksum of x detected barcode will be ignored if setVerifyChecksum is set to true.

Returns:
Wether or not to verify the checksum of the barcode found
See Also:
setVerifyChecksum(boolean)

setVerifyChecksum

public void setVerifyChecksum(boolean value)
Sets whether verify the checksum of x detected barcode. Wrong checksum of x detected barcode will be ignored if it is set to true.

Parameters:
value -
See Also:
getVerifyChecksum()

getScanStep

public int getScanStep()
Gets how many pixels reader advances at one time. Increase scan step could increase speed for large pictures but would be less accurate.

Returns:
int
See Also:
setScanStep(int)

setScanStep

public void setScanStep(int value)
Sets how many pixels reader advances at one time. Increase scan step could increase speed for large pictures but would be less accurate.

Parameters:
value - of int
See Also:
getScanStep()

getOrientation

public int getOrientation()
Sets the scan direction for BarCodeReader. Set to -1 for two dimentional barcodes

Returns:
int
See Also:
setOrientation(int), Orientation

setOrientation

public void setOrientation(int value)
Sets the scan direction for BarCodeReader. Set to -1 for two dimentional barcodes

Parameters:
value -
See Also:
getOrientation(), Orientation

getDetectSupplement

public boolean getDetectSupplement()
Gets whether to detect supplement barcode for EAN13, EAN8, BooklandEAN, UPCA, UPCE barcode.

Returns:
boolean
See Also:
setDetectSupplement(boolean), com.aspose.barcode.BarCodeInfo.hasSupplement(), com.aspose.barcode.BarCodeInfo.getSupplementInfo()

setDetectSupplement

public void setDetectSupplement(boolean value)
Sets whether to detect supplenent barcode for EAN13, EAN8, BooklandEAN, UPCA, UPCE barcode.

Parameters:
value - of boolean
See Also:
getDetectSupplement(), com.aspose.barcode.BarCodeInfo.hasSupplement(), com.aspose.barcode.BarCodeInfo.getSupplementInfo()

setImage

public void setImage(java.awt.Image value)
              throws java.lang.Exception
Sets the image for reader to scan

Parameters:
value - of Image
Throws:
java.lang.Exception - when image format not supported

read

public BarCodeInfo[] read()
                   throws java.lang.Exception

Scan the image for barcodes.

Example public void paint(Graphics g) { try { Image img = this.getToolkit().getImage("c:\\test.jpg"); BarCodeReader reader = new BarCodeReader(img); BarCodeInfo[] results = null; results = reader.read(); if(results.length > 0) { g.drawString("barcode found:" + results[0].getCodeText(), 10, 10); } else { g.drawString("barcode not found", 10, 10); } } catch (Exception ex) { ex.printStackTrace(); } }

Throws:
java.lang.Exception