Generate DataBar Barcodes in C++
Overview
The DataBar symbology was introduced at the beginning of the 2000s as a part of the GS1 group of standards. The purpose was to mitigate the problems associated with the use of barcode types developed in the 70s. At the same time, it was necessary to keep the most important feature of 1D barcodes, namely, the possibility of being scanned by laser readers. The DataBar standard includes the following barcode types:
- DataBar Omnidirectional / DataBar Stacked Omnidirectional
- DataBar Truncated / DataBar Stacked
- DataBar Limited
- DataBar Expanded / DataBar Expanded Stacked
All DataBar standards except DataBar Limited can be represented both in two-row or multiple-row (up to 10 rows) forms. This allows adjusting the barcode layout and fitting it in the available area in the case of limited horizontal space. These symbologies have been developed specifically to encode GS1 identification codes for trade items (so-called Application Identifiers). Accordingly, all DataBar symbologies except DataBar Expanded and DataBar Expanded Stacked can be used to encode only trade identifiers defined as Global Trade Item Number (GTIN) exclusively in GTIN12 or GTIN13 digital formats using the 14-digit data structure. In turn, DataBar Expanded enables encoding any set of application identifiers; moreover, it allows including additional information in any form as it supports English alphabet characters (uppercase and lowercase), numerical digits, and 21 punctuation symbols.
Barcode Height Settings
DataBar symbologies can be divided into two main groups: continuous and stacked. In Aspose.BarCode for C++, for each of them there is its own way to adjust barcode height. Details on how to modify barcode height along with code samples and examples of generated barcodes are provided further in the article.
Continuous Barcodes
For continuous symbologies, such as DataBar Omnidirectional, DataBar Truncated, DataBar Limited, and DataBar Expanded, barcode heigh can be set using the BarHeight property of class BarcodeParameters.
Sample DataBar Omnidirectional barcode labels provided below have been generated using different bar height settings.
Bar Height |
Is Set to 30 Pixels |
Is Set to 60 Pixels |
---|---|---|
Stacked Barcodes
In stacked symbologies, such as DataBar Stacked Omnidirectional, DataBar Stacked, and DataBar Expanded Stacked, barcode heigh can be customized by initializing the AspectRatio property of class DataBarParameters. This parameter is defined as a relative coefficient to the XDimension property.
DataBar Stacked Omnidirectional barcode images represented below as examples have been created with different aspect ratio settings.
Aspect Ratio |
Is Set to 15 |
Is Set to 30 |
---|---|---|
Layout Settings for DataBar Expanded Stacked Barcodes
The DataBar Expanded Stacked symbology provides flexible settings for barcode layout by varying the number of rows and columns in a barcode. The Aspose.BarCode library enables combining 22 data segments to form up to 10 strings. Developers can set the values independently for Rows and Columns properties of class DataBarParameters. The value set in the Columns property is the most significant parameter; at first, it is required to specify how many segments need to be placed in a row.
Sample DataBar Expanded Stacked barcode labels given below have been generated with different barcode layout settings.
Layout Settings |
4 Columns |
3 Rows |
6 Columns and 10 Rows |
---|---|---|---|
Compatibility with GS1 Components
Given that DataBar Expanded and DataBar Expanded Stacked symbologies, in theory, allow encoding any text, it may be required to ensure that encoded information is fully compatible with GS1 standards. To enable such controls, class DataBarParameters provides the IsAllowOnlyGS1Encoding property that is aimed to verify the compatibility of the input barcode text with GS Application Identifiers and throws an exception in case of any mismatch. In addition, this property can be used to check the validity of input GTIN values for other DataBar standards.
DataBar Expanded barcode image examples provided below have been created using the GS1 compatible and alternate encodings.
GS1 Compatibility |
GS1 Compatible Encoding |
Alternate Encoding |
---|---|---|
Enable 2D Component
Each of the DataBar symbologies may contain a specific 2D component linkage flag that indicates the presence of an associated 2D barcode that can be placed alongside the generated DataBar barcode label. Usually, such a flag is set in GS1 composite barcode specifications. Aspose.BarCode for C++ enables the Is2DCompositeComponent property of class DataBarParameters that can be used to set this flag manually when required by particular industrial standards without affecting main information encoded in a barcode.
DataBar Expanded barcode images shown below have been generated with different settings for the 2D component flag.
2D Component |
Is Disabled |
Is Enabled |
---|---|---|