PDF417
- 3 minutes to read
Short Description
PDF417 (Portable Data File) is a stacked linear two-dimensional bar code used in a variety of applications; primarily transport, postal, identification card and inventory management. It was invented by Ynjiun Wang at Symbol Technologies in 1991, and has spawned an Open Source decoder project together with an Open Source encoder.
The PDF417 bar code is also called a symbol bar code and usually consists of 3 to 90 rows, each of which is like a small linear bar code.
For more information on this symbology, refer to its Official Standard web page.
Bar Code Properties
The type of a bar code control’s Symbology property is PDF417Generator.
The following properties are specific to the PDF417 type.
XRBarCode.AutoModule/BarCodeControl.AutoModule
Gets or sets whether the Module property value should be calculated automatically based upon the barcode’s size.
-
Gets or sets the number of bar code columns, which allows control of the logic width of the bar code.
PDF417Generator.CompactionMode
Gets or sets whether textual information or a byte array should be used as the bar code’s data.
PDF417Generator.ErrorCorrectionLevel
Gets or sets the amount of redundancy built into the bar code’s coding, to compensate for calculation errors.
-
Gets or sets the number of bar code rows, which allows control of the logic height of the bar code.
PDF417Generator.TruncateSymbol
Gets or sets whether the special end-symbol should be appended to the bar code.
-
Gets or sets the height-to-width ratio of a logical unit’s graphic representation.
Examples
The following code creates a PDF417 bar code and specifies its main properties.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-add-a-bar-code-to-a-report-e167.
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreatePDF417BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to PDF417.
barCode.Symbology = new PDF417Generator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 150;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
//barcode.Module = 3;
// Adjust the properties specific to the bar code type.
((PDF417Generator)barCode.Symbology).Columns = 1;
((PDF417Generator)barCode.Symbology).CompactionMode = PDF417CompactionMode.Text;
((PDF417Generator)barCode.Symbology).ErrorCorrectionLevel = ErrorCorrectionLevel.Level2;
((PDF417Generator)barCode.Symbology).Rows = 9;
((PDF417Generator)barCode.Symbology).TruncateSymbol = false;
((PDF417Generator)barCode.Symbology).YToXRatio = 3;
return barCode;
}
To add the XRBarCode to a report band, handle the report’s XRControl.BeforePrint event.