Barcode Generator for PHP
Barcode Generator for ASP.NET
BCGaztec Class

Aztec code comes from the 2D barcode family. You can encode a lot of information in only one barcode.
All the ASCII characters from 0 to 255 are supported. The barcode size will be determined by the number of data needed to be encoded and the chosen error correction level.
You can pass in ECI mode with the function setTilde().

This class inherits from the BCGBarcode2D class.
This class is also available for WebControl: BCGaztec
Namespace: BarcodeGenerator
Assembly: BarcodeGenerator

BCGaztec's Methods
NameDescription
public methodsetErrorLevel(int level)Sets the error correction level of the barcode
public methodsetSize(int size)Sets the size of the barcode
public methodsetStructureAppend(int snum, int st)Specifies the data will be expended on many barcodes without identifier
public methodsetStructureAppend(int snum, int st, string sname)Specifies the data will be expended on many barcodes with identifier
public methodsetTilde(bool accept)Modifies the use of the tilde character ~
public methodsetRune(int runeNumber)Specifies to draw a Rune
BCGBarcode2D's Methods
No specific methods for this class.
BCGBarcode's Methods
NameDescription
public methodparse(string text)Analyzes a text message to draw afterwards
public methoddraw(ref Bitmap bm)Draws the barcode on the bm
public methodgetMaxSize()Returns a table containing the required size for the image
public methodgetScale()Gets the scale of the barcode
public methodsetScale(int x)Sets the scale of the barcode
public methodsetForegroundColor(BCGColor color)Sets the color for the bars
public methodsetBackgroundColor(BCGColor color)Sets the color for the back (spaces)
public methodsetColor(BCGColor fg, BCGColor bg)Sets the color for the bars and back (spaces)
public methodsetOffsetX(int offsetX)Specifies the X offset
public methodsetOffsetY(int offsetY)Specifies the Y offset

Example
protected void Page_Load(object sender, EventArgs e)
{
BCGColor color_black = new BCGColor(0, 0, 0);
BCGColor color_white = new BCGColor(255, 255, 255);

BCGBarcode2D code = new BCGaztec();
code.setScale(2); // Resolution
code.setErrorLevel(23); // Error Level
code.setSize(BCGaztec.AZTEC_SIZE_SMALLEST); // Size
code.setForegroundColor(color_black); // Color of bars
code.setBackgroundColor(color_white); // Color of spaces
code.setTilde(true); // Activate special characters
code.parse("Code 2D"); // Text

/* Here is the list of the arguments
1 - Filename
2 - Background color */

BCGDrawing drawing = new BCGDrawing(null, color_white);
drawing.setBarcode(code);
drawing.draw();

// Draw (or save) the image into PNG format.
Response.ContentType = "image/png";
drawing.finish(ImageFormat.Png, Response.OutputStream);
}

Methods Explanation
setErrorLevel(int level) — Sets the error correction level of the barcode
Description
It is the error correction level percentage before drawing the barcode.
The level must be between 0 and 99.
The default value is 23.
setSize(int size) — Sets the size of the barcode
Description
The size of the final barcode will be decided automatically depending on the data you give and the error correction level percentage you have chosen.
But, you can specify different values to this method to get a different code. There are the possible values:
  • BCGaztec.AZTEC_SIZE_SMALLEST : The code will be the smallest possible
  • BCGaztec.AZTEC_SIZE_COMPACT : The code will try to be a compact code if possible
  • BCGaztec.AZTEC_SIZE_FULL : The code will be in full mode (with the reference grid)
The default value is BCGaztec.AZTEC_SIZE_SMALLEST.
setStructureAppend(int snum, int st) — Specifies the data will be expended on many barcodes without identifier
Description
The Aztec code data can be separated on many different barcodes.
The first argument is the barcode number (beginning with 1), the second argument is the total number of barcodes you have. No identifier is set for the barcode. Make sure you have no identifier for every barcode in the group.
It is possible to encode the data on a maximum of 26 different barcodes.
Returns
true on success, false on failure.
setStructureAppend(int snum, int st, string sname) — Specifies the data will be expended on many barcodes with identifier
Description
The Aztec code data can be separated on many different barcodes.
The first argument is the barcode number (beginning with 1), the second argument is the total number of barcodes you have. The last argument specifies an identifier for you barcodes group. This argument must stay the same for every barcode.
It is possible to encode the data on a maximum of 26 different barcodes.
Returns
true on success, false on failure.
setTilde(bool accept) — Modifies the use of the tilde character ~
Description
By putting true to this the argument for this method, the tilde characters (ASCII 126) will be processed as special characters. There are the special characters you can write.
  • ~~ : Writes a simple tilde
  • ~F : Writes the FNC1 character
  • ~Exxxxxx : Writes the ECI xxxxxx character with x varying from 0 to 9.

The default value is true.
setRune(int runeNumber) — Specifies to draw a Rune
Description
By calling the function draw(), the Rune number runeNumber will be drawn to the screen. The Runes are special symbols.
Returns
true on success, false on failure.
parse(string text) — Analyzes a text message to draw afterwards
Description
The data you pass to the text argument must be supported by the barcode you use.
Check the introduction of the barcode to obtain more information
draw(ref Bitmap bm) — Draws the barcode on the bm
Description
The value of the bm argument must be a Bitmap image resource. The size of the image can be defined by the value received from getMaxSize().
getMaxSize() — Returns a table containing the required size for the image
Description
Returns a table which the first index is the image width and the second index is the image height. The BCGDrawing class uses this method to create the image resource.
Returns
int[] - [0] is the width, [1] is the height
getScale() — Gets the scale of the barcode
Description
Gets the scale of the barcode. The value is the number of the "smallest" unit in pixel.
Returns
int - value in pixel
setScale(int x) — Sets the scale of the barcode
Description
The barcode will be x times bigger. Then a pixel will be x by x for its size.
setForegroundColor(BCGColor color) — Sets the color for the bars
Description
The color of the bars of the barcode. By default, the color is black. This argument can be a BCGColor class or any other argument that BCGColor can accept in its constructor.
setBackgroundColor(BCGColor color) — Sets the color for the back (spaces)
Description
The color of the back (spaces) of the barcode. By default, the color is white. This argument can be a BCGColor class or any other argument that BCGColor can accept in its constructor.
setColor(BCGColor fg, BCGColor bg) — Sets the color for the bars and back (spaces)
Description
Easy and fast method to sets the color of the bars and back (spaces). Check the setForegroundColor() and setBackgroundColor().
setOffsetX(int offsetX) — Specifies the X offset
Description
Specifies the X offset of the barcode in pixel multiplied by the scale. The required size returned by getMaxSize() will sera modified accordingly.
setOffsetY(int offsetY) — Specifies the Y offset
Description
Specifies the Y offset of the barcode in pixel multiplied by the scale. The required size returned by getMaxSize() will sera modified accordingly.
Select Language: Français