Bar Code Recognition Specifics
- 5 minutes to read
This document describes the main specifics of bar code recognition and how to resolve the most frequently encountered issues when working with bar codes.
This topic consists of the following sections.
- Choose an Appropriate Bar Code Type
- Insert the Function Code One Character (FNC1) or the Application Identifier into a Bar Code
- Export Bar Codes to Different Formats
- Use Bar Codes in Point-of-Sale (POS) Systems
- Common Issues
Choose an Appropriate Bar Code Type
Selecting an appropriate bar code type (symbology) depends on your specific business requirements and the applied industrial standards.
For a list of supported bar codes, see Bar Code Types.
Insert the Function Code One Character (FNC1) or the Application Identifier into a Bar Code
Some encodings enable you to insert a special FNC1 character for separating application identifiers from the rest of the bar code.
According to the GS1 specification, the FNC1 character is always inserted at the first position of the encoded data. Other identifiers can be inserted manually using the default “#“ character.
Although you can use any ASCII character as the FNC1 placeholder, it will not be a part of the encoded data as it does not have any direct ASCII representation.
For the Code 128 symbology, only FNC1 characters are currently supported. At present, there is no way to define FNC2 - 4 characters for this bar code in DevExpress products.
For the list of the available application identifiers, refer to the official documentation at www.gs1.org.
Export Bar Codes to Different Formats
Use the BarCode.Save method to export a bar code to an image file. Static properties of the ImageFormat class allow you to specify an output image format. To save a bar code as a vector image, pass the ImageFormat.Emf parameter to the method.
Use the BarCode.ExportToPdf method to save a bar code in PDF format. This method preserves the bar code in its vector form.
Use Bar Codes in Point-of-Sale (POS) Systems
Bar Code Library is built on top of the .NET Framework that does not provide an out-of-the-box support for any matrix and thermal printers.
To access the internal printer fonts or achieve the fastest printing speed possible, use the native approach suggested by the printer manufacturer. Typically, a manufacturer would provide a special series of control commands that should be directly sent to a printer’s port.
This document section provides solutions to the most common issues that you may encounter when creating bar codes.
The bar code is too “dense”
The more information you wish to encode, the more bars should be drawn and the larger the bar code should become.
The BarCode.Module property specifies the width of the narrowest bar in a bar code. Although you can set this property to a very small Double value, the actual value is determined by the maximum resolution of your bar code printer device. Alternatively, consider using the BarCode.AutoSize option to automatically calculate the optimal bar size based on the current bar code dimensions.
When bar codes are “dense” and you are manually specifying the Module value, make sure that multiplying this value by the bar code printer resolution results in an integer number. Otherwise, rounding errors may occur on calculating the resulting bar width.
For example, when the Module is set to 0.015 inches and the printer resolution is 300 DPI, their product equals 4.5, which may be rounded to 4 or 5 pixels for different bars and result in bar code recognition errors. In this case, the Module property should be set to 0.01333 (to make the bar width equal to 4 pixels) or to 0.01667 (to make the bar width equal to 5 pixels).
The bar code is correctly displayed on the preview but it is not scanned
Make sure that your scanner has been correctly set up to be able to recognize a specific kind of a bar code. If you are not certain about how to operate the scanner properly, please refer to its product manual.
Avoid scanning bar codes from the monitor screen (e.g., using an application installed on your smartphone), because the screen DPI may not be sufficient to effectively recognize each particular bar.
The bar code is correctly displayed on the preview but it is scanned incorrectly
The cause for this problem may be an encoding issue specific to the “binary” input mode.
By default, the .NET Framework and all String objects leverage the UTF-16 encoding (see Character Encoding in the .NET Framework). However, your scanner device may use a different encoding model or even a codepage (i.e., a specific table that maps abstract values to real human-understandable characters). For additional information on this subject, please refer to the specification of your scanner device.
The “There are invalid characters in the text” error occurs
Different bar code symbologies define different ranges of allowed characters under different character sets. To avoid this error, please check the bar code specification.