GS1 - DataBar
- 3 minutes to read
Short Description
The GS1 DataBar bar code is based on a family of symbols often used in the GS1 DataBar Coupon (coupon codes commonly used in retail).
These bar codes can encode up to 14 digits, which makes them suitable for GTIN 8, 12, 13 and 14.
GS1 DataBar Expanded and GS1 DataBar Expanded Stacked can encode up to 74 numeric or 41 alphanumeric characters, and provide the capability to utilize all GS1 Application Identifiers (e.g., expiration date, batch and serial number). These bar codes are often used in manufacturer coupons.
Bar Code Properties
The type of a bar code control’s Symbology property is DataBarGenerator.
The following properties are specific to the GS1 DataBar type.
DataBarGenerator.FNC1Substitute
Specifies the symbol (or set of symbols) in the bar code text that will be replaced with the FNC1 functional character when the bar code’s bars are drawn.
-
Gets or sets the type of a GS1 DataBar bar code.
DataBarGenerator.SegmentsInRow
Gets or sets the number of data segments per row in the Expanded Stacked type of a GS1 DataBar bar code.
Examples
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 CreateDataBarGS1BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to GS1 DataBar.
barCode.Symbology = new DataBarGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 250;
barCode.Height = 160;
// Adjust the properties specific to the bar code type.
((DataBarGenerator)barCode.Symbology).FNC1Substitute = "#";
((DataBarGenerator)barCode.Symbology).SegmentsInRow = 4;
((DataBarGenerator)barCode.Symbology).Type = DataBarType.ExpandedStacked;
return barCode;
}
To add the XRBarCode to a report band, handle the report’s XRControl.BeforePrint event.