com.aspose.barcode
Class BarCodeBuilder

java.lang.Object
  extended by com.aspose.barcode.BarCodeBuilder

public class BarCodeBuilder
extends java.lang.Object

Backend barcode image renderer which could render to file, to Graphics and to serverlet HttpServletResponse. Supported BarCode symmbologies:

 Codabar, Code11, Code128, Code39, Code39 extended, Code93, Code93 extended
 Interleaved 2of5, Standard2of5, MSI, UPCA, UPCE
 
Example
                BarCodeBuilder b = new BarCodeBuilder();
                b.setSymbology(Symbology.CODE128);
                b.setCodeText("12345678");
                try
                {
                        b.save("c:\\test.bmp");
                        b.save("c:\\test.png");
                }
                catch(Exception ex)
                {
                        ex.printStackTrace();
                }
 
Example
        public void paint(Graphics g)
        {
                BarCodeBuilder b = new BarCodeBuilder();
                b.setSymbology(Symbology.CODE128);
                b.setCodeText("12345678");
                b.render(g);
        }
 


Field Summary
static int CODABARSYMBOL_A
           
static int CODABARSYMBOL_B
           
static int CODABARSYMBOL_C
           
static int CODABARSYMBOL_D
           
static int GRAPHICSUNIT_DISPLAY
           
static int GRAPHICSUNIT_DOCUMENT
           
static int GRAPHICSUNIT_INCH
           
static int GRAPHICSUNIT_MILIMETER
           
static int GRAPHICSUNIT_PIXEL
           
static int GRAPHICSUNIT_POINT
           
static int IMAGEQUALITY_ANTIALIAS
           
static int IMAGEQUALITY_DEFAULT
           
static int SYMBOLOGY_CODABAR
           
static int SYMBOLOGY_CODE11
           
static int SYMBOLOGY_CODE39EXTENDED
           
static int SYMBOLOGY_CODE39STANDARD
           
static int SYMBOLOGY_CODE93EXTENDED
           
static int SYMBOLOGY_CODE93STANDARD
           
static int SYMBOLOGY_EAN13
           
static int SYMBOLOGY_EAN8
           
static int SYMBOLOGY_INTERLEAVED2OF5
           
static int SYMBOLOGY_MSI
           
static int SYMBOLOGY_STANDARD2OF5
           
static int SYMBOLOGY_UPCA
           
static int SYMBOLOGY_UPCE
           
static int TEXTALIGN_CENTER
           
static int TEXTALIGN_LEFT
           
static int TEXTALIGN_RIGHT
           
 
Constructor Summary
BarCodeBuilder()
          Constructs a BarCodeBuilder
BarCodeBuilder(int symbology, java.lang.String codeText)
          Constructs a BarCodeBuilder with specific Symbology and CodeText
 
Method Summary
 java.awt.Image generateBarCodeImage()
           Returns an Image instance of the barcode image
 boolean getAutoSize()
           Gets whether auto sizing the barcode image or not.
 java.awt.Color getBackColor()
           Gets the background color of the barcode image, default to white
 float getBarHeight()
           Gets the bar's height for 1D barcodes, measured in com.aspose.barcode.GraphicsUnit
 java.awt.Color getBorderColor()
           Gets border's color of the barcode image
 boolean getBorderVisible()
           Gets whether to draw the border or not
 float getBorderWidth()
           Gets border's width of a barcode image.
 Caption getCaptionAbove()
           Gets CaptionAbove of the barcode image.
 Caption getCaptionBelow()
           Gets the caption below the barcode image
 int getCodabarStartSymbol()
           Gets the start symbol for codabar types of barcode
 int getCodabarStopSymbol()
           Gets the stop symbol of codabar types of barcode
 int getCode128Set()
           Gets code set for code128 types of barcode
 java.lang.String getCodeText()
           Gets the code text of the barcode, code text is the data encoded into the barcode image Some barcode symbologies may require certain types of code text, such as UPCA and UPCE require numbers only
 java.awt.Color getCodeTextColor()
           Gets the human readable code text's color
 java.awt.Font getCodeTextFont()
           Gets the code text's font of a barcode.
 boolean getCodeTextVisible()
           Gets whether or not to show the human readable code text
 boolean getEnableChecksum()
           Gets whether checksum is enabled.
 java.awt.Color getForeColor()
           Gets the foreground color of the barcode image, if it's for web servlet render caption's color and code text's color may be all reduced to one color
 int getGraphicsUnit()
           Gets the measurement of graphics unit, default to millimeter
 float getHeight()
           Gets the height of a barcode image.
 int getImageQuality()
           Gets the image quality of the barcode image, it's not recommended to use the anti alias setting, that will make the barcode image harder to read by machine
 Margins getMargins()
           Gets the marginal size of an barcode image, the area around the barcode.
 Resolution getResolution()
           Gets the resolution of the barcode image
 float getRotationAngle()
           Gets the rotation angle of the barcode image defaults to 0 degree
 java.lang.String[] getSupportedImageFormats()
          Gets supporting image format (suffixes) by Save method
 int getSymbology()
           Gets the symbology of BarCodeBuilder.
 float getWideNarrowRatio()
           Gets wide bars to narrow bars ratio for some types of one dimensional barcode
 float getWidth()
           Gets the width of a barcode image.
 float getXDimension()
           Gets the width of a smallest bar, or the smallest module's width of 2D barcodes measured in GraphicsUnit
 void render(java.awt.Graphics g)
           Renders barcode by Graphics g
 void render(java.awt.Graphics2D g)
           Renders barcode by Graphics2D g
 void render(javax.servlet.http.HttpServletResponse response)
           Renders barcode to servlet
 void save(java.io.File file, java.lang.String imageFormat)
           Saves the barcode image to file
 void save(java.lang.String filename)
           Saves the barcode image to file
 void save(java.lang.String filename, java.lang.String imageFormat)
           Saves the barcode image to file
 void setAutoSize(boolean value)
           Sets whether auto sizing the barcode image or not.
 void setBackColor(java.awt.Color value)
           Sets the background color of the barcode image, default to white
 void setBarHeight(float value)
           Sets the bar's height for 1D barcodes, measured in com.aspose.barcode.GraphicsUnit
 void setBorderColor(java.awt.Color value)
           Sets border's color of the barcode image
 void setBorderVisible(boolean value)
           Sets whether to draw the border or not
 void setBorderWidth(float value)
           Sets border's width of a barcode image.
 void setCaptionAbove(Caption value)
           Sets the CaptionAbove of the barcode image.
 void setCaptionBelow(Caption value)
           Sets the caption below the barcode image
 void setCodabarStartSymbol(int value)
           Sets the start symbol for codabar types of barcode
 void setCodabarStopSymbol(int value)
           Sets the stop symbol of codabar types of barcode
 void setCode128Set(int value)
           Sets code set for code128 types of barcode
 void setCodeText(java.lang.String value)
           Sets the code text of the barcode, code text is the data encoded into the barcode image If code text is null or empty, exception will be thrown.
 void setCodeTextColor(java.awt.Color value)
           Sets the human readable code text's color
 void setCodeTextFont(java.awt.Font value)
           Sets the code text's font of a barcode.
 void setcodeTextVisible(boolean value)
           Sets whether or not to show the human readable code text, some symbologies of barcode may ignore this setting
 void setEnableChecksum(boolean value)
           Sets wether checksum is enabled.
 void setForeColor(java.awt.Color value)
           Gets the foreground color of the barcode image, if it's for web servlet render caption's color and code text's color may be all reduced to one color
 void setGraphicsUnit(int value)
           Sets the measurement of graphics unit, default to millimeter
 void setHeight(float value)
           Sets the height of a barcode image, if auto size is set to true, Width and Height settings will be ignored
 void setImageQuality(int value)
           Sets the image quality of the barcode image, it's not recommended to use the anti alias setting, that will make the barcode image harder to read by machine
 void setMargins(Margins value)
           Sets the marginal size of an barcode image, the area around the barcode.
 void setResolution(Resolution value)
           Sets the resolution of the barcode image
 void setRotationAngle(float value)
           Sets the rotation angle of the barcode image, default to 0 degree, if rotation angle not not equal to 0, 90, 180 or 270, the barcode maybe jagged, setImageQuality to anti-alias to solve this problem
 void setSymbology(int value)
           Sets the symbology of BarCodeBuilder.
 void setWideNarrowRatio(float value)
           Sets wide bars to narrow bars ratio for some types of one dimensional barcode, default to 3.0
 void setWidth(float value)
           Sets the width of a barcode image, if auto size is set to true, Width and Height settings will be ignored
 void setXDimension(float value)
           Sets the width of a smallest bar, or the smallest module's width of 2D barcodes measured in GraphicsUnit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYMBOLOGY_CODABAR

public static final int SYMBOLOGY_CODABAR
See Also:
Constant Field Values

SYMBOLOGY_CODE11

public static final int SYMBOLOGY_CODE11
See Also:
Constant Field Values

SYMBOLOGY_CODE39EXTENDED

public static final int SYMBOLOGY_CODE39EXTENDED
See Also:
Constant Field Values

SYMBOLOGY_CODE39STANDARD

public static final int SYMBOLOGY_CODE39STANDARD
See Also:
Constant Field Values

SYMBOLOGY_CODE93EXTENDED

public static final int SYMBOLOGY_CODE93EXTENDED
See Also:
Constant Field Values

SYMBOLOGY_CODE93STANDARD

public static final int SYMBOLOGY_CODE93STANDARD
See Also:
Constant Field Values

SYMBOLOGY_EAN13

public static final int SYMBOLOGY_EAN13
See Also:
Constant Field Values

SYMBOLOGY_EAN8

public static final int SYMBOLOGY_EAN8
See Also:
Constant Field Values

SYMBOLOGY_INTERLEAVED2OF5

public static final int SYMBOLOGY_INTERLEAVED2OF5
See Also:
Constant Field Values

SYMBOLOGY_MSI

public static final int SYMBOLOGY_MSI
See Also:
Constant Field Values

SYMBOLOGY_STANDARD2OF5

public static final int SYMBOLOGY_STANDARD2OF5
See Also:
Constant Field Values

SYMBOLOGY_UPCA

public static final int SYMBOLOGY_UPCA
See Also:
Constant Field Values

SYMBOLOGY_UPCE

public static final int SYMBOLOGY_UPCE
See Also:
Constant Field Values

CODABARSYMBOL_A

public static final int CODABARSYMBOL_A
See Also:
Constant Field Values

CODABARSYMBOL_B

public static final int CODABARSYMBOL_B
See Also:
Constant Field Values

CODABARSYMBOL_C

public static final int CODABARSYMBOL_C
See Also:
Constant Field Values

CODABARSYMBOL_D

public static final int CODABARSYMBOL_D
See Also:
Constant Field Values

GRAPHICSUNIT_DISPLAY

public static final int GRAPHICSUNIT_DISPLAY
See Also:
Constant Field Values

GRAPHICSUNIT_DOCUMENT

public static final int GRAPHICSUNIT_DOCUMENT
See Also:
Constant Field Values

GRAPHICSUNIT_INCH

public static final int GRAPHICSUNIT_INCH
See Also:
Constant Field Values

GRAPHICSUNIT_MILIMETER

public static final int GRAPHICSUNIT_MILIMETER
See Also:
Constant Field Values

GRAPHICSUNIT_PIXEL

public static final int GRAPHICSUNIT_PIXEL
See Also:
Constant Field Values

GRAPHICSUNIT_POINT

public static final int GRAPHICSUNIT_POINT
See Also:
Constant Field Values

TEXTALIGN_CENTER

public static final int TEXTALIGN_CENTER
See Also:
Constant Field Values

TEXTALIGN_LEFT

public static final int TEXTALIGN_LEFT
See Also:
Constant Field Values

TEXTALIGN_RIGHT

public static final int TEXTALIGN_RIGHT
See Also:
Constant Field Values

IMAGEQUALITY_DEFAULT

public static final int IMAGEQUALITY_DEFAULT
See Also:
Constant Field Values

IMAGEQUALITY_ANTIALIAS

public static final int IMAGEQUALITY_ANTIALIAS
See Also:
Constant Field Values
Constructor Detail

BarCodeBuilder

public BarCodeBuilder()
Constructs a BarCodeBuilder


BarCodeBuilder

public BarCodeBuilder(int symbology,
                      java.lang.String codeText)
Constructs a BarCodeBuilder with specific Symbology and CodeText

Parameters:
symbology - Symbology of barcode
codeText - Data to be encoded
See Also:
Symbology
Method Detail

getSymbology

public int getSymbology()

Gets the symbology of BarCodeBuilder. Supported Symbologies:

 Codabar, Code11, Code128, Code39, Code39 extended, Code93, Code93 extended
 Interleaved 2of5, Standard2of5, MSI, UPCA, UPCE
 
Example
        BarCodeBuilder b = new BarCodeBuilder();
        if(b.getSymbology() != Symbology.CODE128)
        {
                b.setSymbology(Symbology.CODE128)
        }
 

See Also:
Symbology, setSymbology(int value)

setSymbology

public void setSymbology(int value)

Sets the symbology of BarCodeBuilder. Supported symbologies:

 Codabar, Code11, Code128, Code39, Code39 extended, Code93, Code93 extended
 Interleaved 2of5, Standard2of5, MSI, UPCA, UPCE
 

Parameters:
value - from com.aspose.barcode.Symbology

Example

        BarCodeBuilder b = new BarCodeBuilder();
        if(b.getSymbology() != Symbology.CODE128)
        {
                b.setSymbology(Symbology.CODE128)
        }
 
See Also:
getSymbology(), Symbology

getCaptionAbove

public Caption getCaptionAbove()

Gets CaptionAbove of the barcode image. Evaluation version of aspose barcode will force an Aspose.Demo CaptionAbove

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.getCaptionAbove().setText("This is the caption above");
 

Returns:
com.aspose.barcode.Caption
See Also:
setCaptionAbove(Caption), Caption, setCaptionBelow(Caption), getCaptionBelow()

setCaptionAbove

public void setCaptionAbove(Caption value)

Sets the CaptionAbove of the barcode image. Evaluation version of aspose barcode will force an Aspose.Demo CaptionAbove

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setCaptionAbove(new Caption("this is a caption"));
 

Parameters:
value - of com.aspose.barcode.Caption
See Also:
Caption, getCaptionAbove(), getCaptionBelow(), setCaptionBelow(Caption)

getCaptionBelow

public Caption getCaptionBelow()

Gets the caption below the barcode image

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.getCaptionBelow().setVisible(false);
 

Returns:
com.aspose.barcode.Caption
See Also:
Caption, setCaptionBelow(Caption), getCaptionAbove(), setCaptionAbove(Caption)

setCaptionBelow

public void setCaptionBelow(Caption value)

Sets the caption below the barcode image

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setCaptionBelow(new Caption("Caption below the barcode image"));
 

Parameters:
value - of com.aspose.barcode.Caption
See Also:
getCaptionBelow(), setCaptionAbove(Caption), getCaptionAbove(), Caption

getCodeText

public java.lang.String getCodeText()

Gets the code text of the barcode, code text is the data encoded into the barcode image Some barcode symbologies may require certain types of code text, such as UPCA and UPCE require numbers only

Returns:
String
See Also:
setCodeText(String)

setCodeText

public void setCodeText(java.lang.String value)

Sets the code text of the barcode, code text is the data encoded into the barcode image If code text is null or empty, exception will be thrown. Some barcode symbologies may require certain types of code text, such as UPCA and UPCE require numbers only

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setCodeText("12345678");
        b.setSymbology(Symbology.UPCA);
        try
        {
                b.save("test.jpg");
        }
        catch(Exception ex)
        {
                ex.printStackTrace();
        }
 

Parameters:
value - of String
See Also:
getCodeText()

getCodeTextFont

public java.awt.Font getCodeTextFont()

Gets the code text's font of a barcode. barcode image normally has human readable code text printed along with the machine readable barcode. Code text font specifies human readable code text's font style. Default font is Serif.

Returns:
java.awt.Font
See Also:
Font, setCodeTextFont(Font)

setCodeTextFont

public void setCodeTextFont(java.awt.Font value)

Sets the code text's font of a barcode. barcode image normally has human readable code text printed along with the machine readable barcode. Code text font specifies human readable code text's font style. Default font is Serif.

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setCodeTextFont(new Font("Serif", Font.BOLD + Font.ITALIC, 20));
 

Parameters:
value - of java.awt.Font
See Also:
Font, getCodeTextFont()

getBorderVisible

public boolean getBorderVisible()

Gets whether to draw the border or not

Returns:
boolean
See Also:
setBorderVisible(boolean), getBorderColor(), getBorderWidth(), setBorderColor(Color), setBorderWidth(float)

setBorderVisible

public void setBorderVisible(boolean value)

Sets whether to draw the border or not

Parameters:
value - of boolean
See Also:
getBorderVisible(), getBorderColor(), getBorderWidth(), setBorderColor(Color), setBorderWidth(float)

getBorderWidth

public float getBorderWidth()

Gets border's width of a barcode image. measured by GraphicsUnit, defaulted: millimeter

Returns:
border's width if visible
See Also:
GraphicsUnit, getBorderColor(), setBorderColor(Color), getBorderVisible(), setBorderVisible(boolean)

setBorderWidth

public void setBorderWidth(float value)

Sets border's width of a barcode image. measured by GraphicsUnit, defaulted: millimeter

Parameters:
value - greater or equal to zero
See Also:
GraphicsUnit, getBorderColor(), setBorderColor(Color), getBorderVisible(), setBorderVisible(boolean)

getEnableChecksum

public boolean getEnableChecksum()

Gets whether checksum is enabled. Some symbologies such as UPCA, UPCE require Checksum to be presented, they will ignore enable checksum setting


setEnableChecksum

public void setEnableChecksum(boolean value)

Sets wether checksum is enabled. Some symbologies such as UPCA, UPCE require Checksum to be presented, they will ignore enable checksum setting


getMargins

public Margins getMargins()

Gets the marginal size of an barcode image, the area around the barcode. If autosize option is set to true, marginal area will grow automatically if captions won't fit in

BarCodeBuilder b = new BarCodeBuilder(); b.setGraphicsUnit(GraphicsUnit.MILIMETER); //10 millimeters marginal area at the bottom and the left b.getMargins().setBottom(10); b.getMargins().setLeft(10);

Returns:
Current margin settings
See Also:
Margins, setMargins(Margins)

setMargins

public void setMargins(Margins value)

Sets the marginal size of an barcode image, the area around the barcode. If autosize option is set to true, marginal area will grow automatically if captions won't fit in

BarCodeBuilder b = new BarCodeBuilder(); b.setMargins(new Margins(10, 10, 10, 10));

See Also:
getMargins(), Margins

getRotationAngle

public float getRotationAngle()

Gets the rotation angle of the barcode image defaults to 0 degree

Returns:
rotation angle

setRotationAngle

public void setRotationAngle(float value)

Sets the rotation angle of the barcode image, default to 0 degree, if rotation angle not not equal to 0, 90, 180 or 270, the barcode maybe jagged, setImageQuality to anti-alias to solve this problem

Example

BarCodeBuilder b = new BarCodeBuilder(); b.setImageQuality(ImageQuality.ANTI_ALIAS); //setting up rotation angle to 45 degree b.setRotationAngle(45);

Parameters:
value - of float, rotation angle
See Also:
ImageQuality, getRotationAngle()

getXDimension

public float getXDimension()

Gets the width of a smallest bar, or the smallest module's width of 2D barcodes measured in GraphicsUnit

See Also:
GraphicsUnit, setXDimension(float)

setXDimension

public void setXDimension(float value)

Sets the width of a smallest bar, or the smallest module's width of 2D barcodes measured in GraphicsUnit

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setGraphicsUnit(GraphicsUnit.MILIMETER);
        b.setXDimension(0.5f);
 

Parameters:
value - of float, xDimension values measured in com.aspose.barcode.GraphicsUnit

getBarHeight

public float getBarHeight()

Gets the bar's height for 1D barcodes, measured in com.aspose.barcode.GraphicsUnit

Returns:
bar's height of one dimensional barcode
See Also:
setBarHeight(float), GraphicsUnit

setBarHeight

public void setBarHeight(float value)

Sets the bar's height for 1D barcodes, measured in com.aspose.barcode.GraphicsUnit

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setGraphicsUnit(GraphicsUnit.MILIMETER);
        b.setBarHeight(20f);
 

Parameters:
value - of float, bar's height of one dimensional barcode

getGraphicsUnit

public int getGraphicsUnit()

Gets the measurement of graphics unit, default to millimeter

Returns:
com.aspose.barcode.GraphicsUnit
See Also:
GraphicsUnit

setGraphicsUnit

public void setGraphicsUnit(int value)

Sets the measurement of graphics unit, default to millimeter

Example

        BarCodeBuilder b = new BarCodeBuilder();
        //graphics unit set to pixel
        b.setGraphicsUnit(GraphicsUnit.PIXEL);
        //the smallest bar's width will be 2 pixel
        b.setXDimension(2);
        //bar's height of one dimensional barcode will be 20 pixels
        b.setBarHeight(20);
 

Parameters:
value - of int, com.aspose.barcode.GraphicsUnit
See Also:
GraphicsUnit

getForeColor

public java.awt.Color getForeColor()

Gets the foreground color of the barcode image, if it's for web servlet render caption's color and code text's color may be all reduced to one color

Returns:
java.awt.Color
See Also:
setForeColor(Color)

setForeColor

public void setForeColor(java.awt.Color value)

Gets the foreground color of the barcode image, if it's for web servlet render caption's color and code text's color may be all reduced to one color

Parameters:
value - of Color, java.awt.Color
See Also:
Color, setForeColor(Color)

getBackColor

public java.awt.Color getBackColor()

Gets the background color of the barcode image, default to white

Returns:
java.awt.Color
See Also:
Color, getForeColor()

setBackColor

public void setBackColor(java.awt.Color value)

Sets the background color of the barcode image, default to white

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setBackColor(Color.WHITE);
 

Parameters:
value - of Color, java.awt.Color
See Also:
Color, getBackColor()

getCodeTextColor

public java.awt.Color getCodeTextColor()

Gets the human readable code text's color

Returns:
java.awt.Color
See Also:
setCodeTextColor(Color), Color

setCodeTextColor

public void setCodeTextColor(java.awt.Color value)

Sets the human readable code text's color

Parameters:
value - of Color, java.awt.Color
See Also:
setCodeTextColor(Color)

getResolution

public Resolution getResolution()

Gets the resolution of the barcode image

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.getResolution().setDpiX(96);
        b.getResolution().setDpiY(96);
 

Returns:
com.aspose.barcode.Resolution
See Also:
setResolution(Resolution), Resolution

setResolution

public void setResolution(Resolution value)

Sets the resolution of the barcode image

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setResolution(new Resolution(96, 96));
 

Parameters:
value - of Resolution, com.aspose.barcode.Resolution
See Also:
Resolution, getResolution()

getCodeTextVisible

public boolean getCodeTextVisible()

Gets whether or not to show the human readable code text

See Also:
setcodeTextVisible(boolean)

setcodeTextVisible

public void setcodeTextVisible(boolean value)

Sets whether or not to show the human readable code text, some symbologies of barcode may ignore this setting

See Also:
getCodeTextVisible()

getImageQuality

public int getImageQuality()

Gets the image quality of the barcode image, it's not recommended to use the anti alias setting, that will make the barcode image harder to read by machine

Returns:
com.aspose.barcode.ImageQuality
See Also:
setImageQuality(int), ImageQuality

setImageQuality

public void setImageQuality(int value)

Sets the image quality of the barcode image, it's not recommended to use the anti alias setting, that will make the barcode image harder to read by machine

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setImageQuality(ImageQuality.ANTI_ALIAS);
 

Parameters:
value - of ImageQuality, com.aspose.barcode.ImageQuality
See Also:
ImageQuality

getCodabarStartSymbol

public int getCodabarStartSymbol()

Gets the start symbol for codabar types of barcode

Returns:
com.aspose.barcode.CodabarSymbol
See Also:
CodabarSymbol

setCodabarStartSymbol

public void setCodabarStartSymbol(int value)

Sets the start symbol for codabar types of barcode

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setCodabarStartSymbol(CodabarSymbol.A);
 

Parameters:
value - of CodabarSymbol, com.aspose.barcode.CodabarSymbol
See Also:
CodabarSymbol

getCodabarStopSymbol

public int getCodabarStopSymbol()

Gets the stop symbol of codabar types of barcode

Returns:
com.aspose.barcode.CodabarSymbol
See Also:
CodabarSymbol, setCodabarStopSymbol(int)

setCodabarStopSymbol

public void setCodabarStopSymbol(int value)

Sets the stop symbol of codabar types of barcode

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setCodabarStopSymbol(CodabarSymbol.A);
 

Parameters:
value - of CodarbarSymbol, com.aspose.barcode.CodarbarSymbol
See Also:
CodabarSymbol, getCodabarStopSymbol()

getCode128Set

public int getCode128Set()

Gets code set for code128 types of barcode

Returns:
com.aspose.barcode.Code128Set
See Also:
Code128Set

setCode128Set

public void setCode128Set(int value)

Sets code set for code128 types of barcode

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setSymbology(Symbology.CODE128);
        b.setCode128Set(Code128Set.AUTO);
 

Parameters:
value - of Code128Set, com.aspose.barcode.Code128Set
See Also:
Code128Set

getWideNarrowRatio

public float getWideNarrowRatio()

Gets wide bars to narrow bars ratio for some types of one dimensional barcode

See Also:
setWideNarrowRatio(float)

setWideNarrowRatio

public void setWideNarrowRatio(float value)

Sets wide bars to narrow bars ratio for some types of one dimensional barcode, default to 3.0

See Also:
getWideNarrowRatio()

getAutoSize

public boolean getAutoSize()

Gets whether auto sizing the barcode image or not. If auto size set to false, image size will be decided by width and height settings

See Also:
setWidth(float), setHeight(float)

setAutoSize

public void setAutoSize(boolean value)

Sets whether auto sizing the barcode image or not. If auto size set to false, image size will be decided by width and height settings

See Also:
setWidth(float), setHeight(float)

getWidth

public float getWidth()

Gets the width of a barcode image.

See Also:
setWidth(float)

setWidth

public void setWidth(float value)

Sets the width of a barcode image, if auto size is set to true, Width and Height settings will be ignored

See Also:
setAutoSize(boolean), getWidth()

getHeight

public float getHeight()

Gets the height of a barcode image.

See Also:
setHeight(float)

setHeight

public void setHeight(float value)

Sets the height of a barcode image, if auto size is set to true, Width and Height settings will be ignored

See Also:
getHeight(), setAutoSize(boolean)

getBorderColor

public java.awt.Color getBorderColor()

Gets border's color of the barcode image

Returns:
java.awt.Color
See Also:
setBorderColor(Color)

setBorderColor

public void setBorderColor(java.awt.Color value)

Sets border's color of the barcode image

Parameters:
value - of Color, java.awt.Color
See Also:
Color

save

public void save(java.lang.String filename)
          throws java.io.IOException,
                 BarCodeException

Saves the barcode image to file

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setSymbology(Symbology.CODE128);
        b.setCodeText("1234566");
        //save as bmp
        b.save("C:\\test.bmp");
        //save as jpg
        b.save("c:\\test.jpg");
        //save to current directory as png
        b.save("test.png");
 

Parameters:
filename - of String, full path of the image including file extension
Throws:
java.io.IOException
BarCodeException

getSupportedImageFormats

public java.lang.String[] getSupportedImageFormats()
Gets supporting image format (suffixes) by Save method

Returns:
formats String[]
See Also:
save(File, String), save(String, String)

save

public void save(java.lang.String filename,
                 java.lang.String imageFormat)
          throws java.io.IOException,
                 BarCodeException

Saves the barcode image to file

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setSymbology(Symbology.CODE128);
        b.setCodeText("1234566");
        //save as bmp
        b.save("C:\\test.bmp", "bmp");
        //save as jpg
        b.save("c:\\test.jpg", "jpg");
        //save to current directory as png
        b.save("test.png", "png");
 

Parameters:
filename - full path of image to be saved
imageFormat - image format such as "bmp", "jpg", "jpeg"
Throws:
java.io.IOException
BarCodeException
See Also:
getSupportedImageFormats()

save

public void save(java.io.File file,
                 java.lang.String imageFormat)
          throws java.io.IOException,
                 BarCodeException

Saves the barcode image to file

Example

        BarCodeBuilder b = new BarCodeBuilder();
        b.setSymbology(Symbology.CODE128);
        b.setCodeText("1234566");
        //save as bmp
        b.save(new File("C:\\test.bmp"), "bmp");
 

Parameters:
file - target file
imageFormat - image format such as "bmp", "jpg", "jpeg"
Throws:
java.io.IOException
BarCodeException

generateBarCodeImage

public java.awt.Image generateBarCodeImage()

Returns an Image instance of the barcode image

Returns:
Image instance

render

public void render(java.awt.Graphics g)

Renders barcode by Graphics g

Example

 
 public class AppletSample extends Applet 
 {
                public void paint(Graphics g)
                {
                        BarCodeBuilder b = new BarCodeBuilder();
                        b.setSymbology(Symbology.CODE128);
                        b.setCodeText("12345678");
                        b.render(g);
                }
        }
 

Parameters:
g - java.awt.Graphics
See Also:
Graphics

render

public void render(java.awt.Graphics2D g)

Renders barcode by Graphics2D g

Parameters:
g - java.awt.Graphics2D
See Also:
Graphics2D

render

public void render(javax.servlet.http.HttpServletResponse response)
            throws java.io.IOException,
                   javax.servlet.ServletException

Renders barcode to servlet

Example

 import java.io.IOException;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;

 import com.aspose.barcode.*;
 
 public class ServletSample extends HttpServlet 
 {
        public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
        {
                BarCodeBuilder b = new BarCodeBuilder();
                b.setSymbology(Symbology.CODE128);
                b.setCodeText("12345678");
                b.render(response);
        }
 }
 

Parameters:
response - HttpServletResponse
Throws:
java.io.IOException
javax.servlet.ServletException
See Also:
HttpServletResponse