Manual - PDF417
Introduction
PDF417 code comes from the 2D barcode family. You can encode a large amount of information within a single barcode.
All the ASCII characters from 0 to 255 are supported. PDF417 encodes the data differently based on the type of characters provided. Some characters are encoded with a higher compression level. See the compression level on the technical page.
This class inherits the BCGBarcode2D class.
Example
Methods
BCGpdf417's Methods
- GetQuietZone() — Gets if the quiet zone will be drawn
-
SetQuietZone(bool
quietZone ) — Specifies to draw a quiet zone around the barcode - GetCompact() — Gets if the barcode will be compact/truncated
-
SetCompact(bool
compact ) — Specifies if the barcode must be compact/truncated - GetColumn() — Gets the number of data column
-
SetColumn(int
column ) — Sets the number of data column - GetErrorLevel() — Gets the error correction level of the barcode
-
SetErrorLevel(int
level ) — Sets the error correction level of the barcode - GetRatio() — Gets the ratio for printing
-
SetRatio(int
ratio ) — Sets the ratio for printing
BCGBarcode2D's Methods
-
SetScaleX(int
scaleX ) — Sets the scaling X for the barcode -
SetScaleY(int
scaleY ) — Sets the scaling Y for the barcode
BCGBarcode's Methods
-
Parse(string
text ) — Analyzes atext message to draw afterwards -
Draw(Graphics
image ) — Draws the barcode on theimage -
GetDimension(int
width , intheight ) — Returns an array containing the required size for the image - GetScale() — Gets the scale of the barcode
-
SetScale(int
scale ) — Sets the scale of the barcode - GetForegroundColor() — Gets the color of the bars
-
SetForegroundColor(BCGColor
color ) — Sets the color of the bars - GetBackgroundColor() — Gets the color of the spaces
-
SetBackgroundColor(BCGColor
color ) — Sets the color of the spaces -
SetColor(BCGColor
foregroundColor , BCGColorbackgroundColor ) — Sets the color of the bars and spaces - GetOffsetX() — Gets the X offset
-
SetOffsetX(int
value ) — Sets the X offset - GetOffsetY() — Gets the Y offset
-
SetOffsetY(int
value ) — Sets the Y offset -
AddLabel(BCGLabel
label ) — Adds a label to the graphic -
RemoveLabel(BCGLabel
label ) — Removes a label from the graphic - ClearLabels() — Removes the labels from the graphic
Code Example
var colorBlack = new BCGColor(Color.Black);
var colorWhite = new BCGColor(Color.White);
// Barcode Part
var code = new BCGpdf417();
code.SetScale(2);
code.SetForegroundColor(colorBlack);
code.SetBackgroundColor(colorWhite);
code.SetErrorLevel(2);
code.SetCompact(false);
code.SetQuietZone(true);
code.Parse("PDF417");
// Drawing Part
var drawing = new BCGDrawing(code, colorWhite);
var memoryStream = new MemoryStream();
await drawing
.FinishAsync(BCGDrawing.ImageFormat.Png, memoryStream);
Method explanations
-
GetQuietZone()
—
Gets if the quiet zone will be drawn
Returns
bool -true if activated,false otherwise -
SetQuietZone(bool
quietZone ) — Specifies to draw a quiet zone around the barcodeDescriptionTo be read correctly, the PDF417 must have a quiet zone around the image. You can, however, turn this off.
The default value is true. -
GetCompact()
—
Gets if the barcode will be compact/truncated
DescriptionGets if the barcode will be compact/truncated.Returns
bool -true if compact/truncated -
SetCompact(bool
compact ) — Specifies if the barcode must be compact/truncatedDescriptionCuts the barcode by removing the 2 last columns on the right. Your barcode will be smaller but harder to read.
The default value is false. -
GetColumn()
—
Gets the number of data column
DescriptionGets the number of columns.Returns
int -
SetColumn(int
column ) — Sets the number of data columnDescriptionSpecifies the number of data columns you want to write. You can spread your data more horizontally than vertically by modifying this parameter.
The number of columns must be between 1 and 30.
Setting the value to -1 makes the barcode calculate this number automatically and optimize it.
The default value is -1. -
GetErrorLevel()
—
Gets the error correction level of the barcode
DescriptionGets the error level.Returns
int -
SetErrorLevel(int
level ) — Sets the error correction level of the barcodeDescriptionThis is the error correction level which allows you to detect and correct errors in the barcode.
The level must be between 0 and 8.
Setting this value calculates the error level automatically by trying to obtain optimal error detection.
The number of keywords you write will be restricted depending on the error level you choose. See the technical page for more information.
The default value is -1. -
GetRatio()
—
Gets the ratio for printing
DescriptionGets the ratio for printing.Returns
int -
SetRatio(int
ratio ) — Sets the ratio for printingDescriptionSets the ratio for printing. This is used only if the number of columns is chosen automatically since this parameter will affect the number of columns in your barcode.
If the number is under 1, the barcode will be spread more horizontally.
The default value is -1.
-
SetScaleX(int
scaleX ) — Sets the scaling X for the barcodeDescriptionThe width in pixel of one module.
The default value is 1.
Note that this method is public. -
SetScaleY(int
scaleY ) — Sets the scaling Y for the barcodeDescriptionThe height in pixel of one module.
The default value is 1.
Note that this method is public.
-
Parse(string
text ) — Analyzes atext message to draw afterwardsDescriptionThe data you pass to thetext argument must be supported by the type of barcode you use.
Check each barcode's introduction section to obtain more information on how to use this method within each symbology. -
Draw(Graphics
image ) — Draws the barcode on theimage DescriptionThe value of theimage argument must be an image resource. The size of the image can be defined by the value received fromGetDimension() . -
GetDimension(int
width , intheight ) — Returns an array containing the required size for the imageDescriptionReturns an array in which the first index is the image width and the second index is the image height.
The arguments are used to specify the starting point of the drawing. Should be 0 for both.
TheBCGDrawing class uses this method to create the image resource.Returnsarray(int, int) - [0] is the width, [1] is the height -
GetScale()
—
Gets the scale of the barcode
DescriptionGets the scale of the barcode. The value is the number of the "smallest" unit in pixel.Returns
int - value in pixels -
SetScale(int
scale ) — Sets the scale of the barcodeDescriptionThe barcode will bex times bigger. Then a pixel will bex byx for its size. -
GetForegroundColor()
—
Gets the color of the bars
DescriptionGets the color of the bars of the barcode.Returns
-
SetForegroundColor(BCGColor
color ) — Sets the color of the bars -
GetBackgroundColor()
—
Gets the color of the spaces
DescriptionGets the color of the spaces of the barcode.Returns
-
SetBackgroundColor(BCGColor
color ) — Sets the color of the spaces -
SetColor(BCGColor
foregroundColor , BCGColorbackgroundColor ) — Sets the color of the bars and spacesDescriptionAn easy and fast method to set the color of the bars and spaces. Check theSetForegroundColor() andSetBackgroundColor() . -
GetOffsetX()
—
Gets the X offset
DescriptionGets the X offset of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
SetOffsetX(int
value ) — Sets the X offsetDescriptionSpecifies the X offset of the barcode in pixels multiplied by the scale. The required size returned byGetDimension() will be modified accordingly. -
GetOffsetY()
—
Gets the Y offset
DescriptionGets the Y offset of the barcode in pixels. The value isn't multiplied by the scale.Returns
int - value in pixels -
SetOffsetY(int
value ) — Sets the Y offsetDescriptionSpecifies the Y offset of the barcode in pixels multiplied by the scale. The required size returned byGetDimension() will be modified accordingly. -
AddLabel(BCGLabel
label ) — Adds a label to the graphicDescriptionAdds aBCGLabel object to the drawing. -
RemoveLabel(BCGLabel
label ) — Removes a label from the graphicDescriptionRemoves a specificBCGLabel object from the drawing. -
ClearLabels()
—
Removes the labels from the graphic
DescriptionClears the
BCGLabel objects from the drawing.