Barcode Generation Best Practices
- 3 minutes to read
This help topic explains how to choose a barcode symbology and configure GS1-specific settings.
Choose an Appropriate Barcode Type
Select a barcode symbology based on your business requirements, industry standards, and the type of data you need to encode.
General recommendations:
- Use numeric-only symbologies when you need to encode digits only (for example,
Interleaved 2 of 5). - Use alphanumeric symbologies when you need to encode letters, numbers, and special characters (for example,
Code 39). - Use 2D barcodes when you need to encode large amounts of data in a compact area.
- Use GS1-compatible symbologies when you need to encode application identifiers and comply with GS1 standards (for example,
GS1 DataBar).
Refer to the following help topic for a complete list of supported barcode types: Barcode Types.
Encode GS1 Application Identifiers
Some barcode standards use the FNC1 character to separate GS1 application identifiers from the encoded data.
According to the GS1 specification, the FNC1 character is placed at the beginning of the encoded value. Because FNC1 has no direct ASCII representation, you must specify a placeholder character in the encoded text. The placeholder itself is not included in the generated barcode.
Use the following methods to specify an FNC1 placeholder:
- DataMatrixGS1Options.setFNC1Substitute(java.lang.String)
- QRCodeGS1Options.setFNC1Substitute(java.lang.String)
- EAN128Options.setFNC1Substitute(java.lang.String)
Code 128 barcodes also support FNC2, FNC3, and FNC4 characters.
Configure Module Size
The module size determines the width of the narrowest bar (or smallest element) in a barcode.
Use the setModuleSize(float value) method to specify barcode density:
barCode.setModuleSize(0.02f);
Match Module Size to Printer Resolution
Choose a module size that maps to a whole number of printer pixels.
For example, with a 300 DPI printer:
| Module Size (inches) | Pixels |
|---|---|
| 0.01333 | 4 |
| 0.01500 | 4.5 |
| 0.01667 | 5 |
Avoid values that produce fractional pixel widths because printer rounding can generate inconsistent bar widths and reduce scanning reliability.
Improve Barcode Readability
Include a Quiet Zone
Most barcode scanners require a blank area around the barcode.
For QR Codes, enable the quiet zone:
qrcode.getOptions().setIncludeQuietZone(boolean);
Verify Scanner Configuration
Ensure that the scanner is configured to recognize the barcode symbology you generate.
Print Before Testing
Avoid testing barcode readability directly from a monitor whenever possible. Screen resolution and rendering settings may affect barcode appearance and produce unreliable scanning results.
Note
The Barcode Generation API does not generate printer-specific commands for thermal or matrix printers. To use printer-resident barcode fonts or native printing features, use the printer manufacturer’s SDK or command set.