Skip to main content

Troubleshooting Barcode Generation API for Java

  • 3 minutes to read

Common Issues (FAQ)

This section describes common barcode generation and scanning issues and explains how to resolve them.

The barcode is too “dense”

Larger amounts of encoded data require more bars or modules. The barcode becomes denser and may be difficult to print or scan.

The BarcodeOptions.setModuleSize(float) method specifies the width of the narrowest bar in a barcode. Although you can specify a very small module size, the printer resolution determines the minimum bar width that the device can render accurately.

Note

When you set the module size manually for dense barcodes, make sure that the product of the module size and the printer resolution is an integer value. Otherwise, rounding errors may occur when the API calculates the resulting bar width.

For example, if the module size is 0.015 inches and the printer resolution is 300 DPI, their product equals 4.5. The printer may round this value to 4 or 5 pixels for different bars and cause recognition errors. In this instance, set the module size to 0.01333 (4 pixels) or 0.01667 (5 pixels).

The barcode does not fit into the available space

Larger amounts of encoded data require more bars or modules.

To resolve this issue:

  • Reduce the amount of encoded data.
  • Increase the barcode size.
  • Use a higher-density symbology (for example, QR Code or Code 128).

The barcode appears in the preview but the scanner does not read it

Make sure that the scanner supports the selected barcode symbology and that the symbology is enabled in the scanner configuration. Refer to the scanner documentation or manual for configuration instructions.

Avoid scanning barcodes directly from a monitor. Screen resolution and display scaling may distort bar widths and prevent successful recognition.

The “There are invalid characters in the text” error occurs

Each barcode symbology supports a specific character set and data format. For example, UPC-A supports digits only, while Code 39 supports uppercase letters, digits, and a limited set of special characters.

To resolve this error:

  • Verify that the input data conforms to the selected barcode symbology.
  • Use a symbology that supports the required character set.
  • For QR Code and Data Matrix barcodes, use byte compaction mode when the input contains characters that the current compaction mode does not support.

The exported barcode looks different in PDF and PNG

Raster image formats depend on pixel resolution. PDF and EMF preserve vector information and scale without quality loss.

Use PDF or EMF output for printing and high-resolution scenarios. Use PNG when you need a bitmap image for screen display or web applications.