BIRT Barcode How-Tos


In this article
BIRT Barcode > How to create barcode in BIRT report > Code 39 for BIRT - BIRT Report Barcode Generator for Code 39 generation in Eclipse BIRT project

How to create, print Code 39 in Eclipse BIRT reports?

Using BIRT Barcode Generator plugin to generate Code 39 in Eclipse BIRT reports


In this page, we will explain how to create, embed, print Code 39 barcode images within Eclipse BIRT (Business Intelligence and Reporting Tools) reports. Code 39 (also known as USS Code 39, Code 3/9, Code 3 of 9, USD 3, Alpha39, or Type 39) is a widely used linear barcode symbology that can encode uppercase letters (A through Z), digits (0 through 9), and a handful of special characters such as the dollar sign ($). It is commonly employed in logistics, inventory management, healthcare, and government identification systems due to its simplicity and reliability.


The BarcodeLib BIRT Code 39 Generator is an Eclipse BIRT Custom Extended Report Item built on the BarcodeLib Java Barcode Generator library. It enables you to generate high quality Code 39 barcode images directly in BIRT reports without writing any Java code. All Code 39 property options are configured in the Report Item Property view of your Report Design file (.rptdesign). The plugin is distributed as a single JAR file, requires no registration key or activation code, and is easy to redistribute. It generates high quality Code 39 barcode images in GIF format by default, with support for other raster formats.


BIRT Barcode Code 39 Generator Introduction

The BarcodeLib BIRT Barcode Code 39 Generator is an Eclipse BIRT Custom Extended Report Item that allows you to easily generate and print high quality linear (1D) and two dimensional (2D) barcodes in your BIRT reports. The Code 39 component specifically targets the Code 39 symbology, which is valued for its simplicity, self checking properties, and widespread scanner support.

Valid data scope for standard Code 39 encoding:
  • Numeric digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • Uppercase letters: A through Z
  • Special characters: dash (-), dollar sign ($), percent sign (%), space ( ), period (.), slash (/), plus sign (+)



Valid data scope for Code 39 Full ASCII (Extended) encoding:
  • All 128 ASCII characters (including lowercase letters, punctuation, and control characters). In Full ASCII mode, lowercase letters, additional punctuation, and control characters are represented by sequences of two standard Code 39 characters.



How to Generate Code 39 in a BIRT Report

Now we will explain how to create, print Code 39 barcodes in a BIRT report.
  1. Open the Palette view and add the barcode report item
  2. Edit the barcode parameters
    Right click the barcode item you have added and select Properties from the context menu. This opens the General tab, where you will find all barcode properties.
    • For static text data, enclose the value in double quotation marks (e.g., "12345").
    • For data set expressions, do not use quotes; instead, enter an expression such as row["CUSTOMERNUMBER"].
  3. Change the barcode type to Code 39
    In the General tab, locate the Barcode Type property. Change it from the default (e.g., Code 128) to Code 39. For Full ASCII (extended) mode, select Code 39 Extension or a similar option depending on the plugin version.
  4. Preview the report
    Click the Preview button (or View Report) on the toolbar. A Code 39 barcode image should be printed on your BIRT report.



Code 39 Barcode Data Character Encoding in BIRT

Code 39 supports two encoding modes: Standard Mode and Full ASCII (Extended) Mode.


Code 39 Standard Mode

Standard Code 39 supports 43 valid characters, which are sufficient for many industrial and inventory applications that only require uppercase alphanumeric data and a few special symbols.

Supported characters in Standard Mode:
  • Numeric digits: 0 - 9
  • Uppercase letters: A - Z
  • Special characters: dash (-), dollar sign ($), percent sign (%), space ( ), period (.), slash (/), plus sign (+)
  • Start/Stop character: Code 39 uses the asterisk (*) as a fixed start and stop character. You should not include the asterisk in the raw data; the library adds it automatically during encoding.



Code 39 Full ASCII Mode (Extended)

Code 39 Full ASCII (Extended) supports all 128 ASCII characters (ISO 646 IRV), including lowercase letters, punctuation, and control characters. This mode is achieved by using pairs of standard Code 39 characters to represent the extended set.

Supported characters in Full ASCII Mode:
  • All 128 ASCII characters (values 0 - 127)
  • Lowercase letters (a - z)
  • Punctuation and special symbols (e.g., !, @, #, &, *, (, ), _, {, }, |, :, ", <, >, ?, ~)
  • Control characters (e.g., NUL, SOH, STX, ETX, etc.)
Set the Type property to CODE39EX (or enable the Code 39 extension property) in the Report Item Property view.



Code 39 Check Digit (MOD43) Configuration

Code 39 does not require a check digit by default. However, enabling the optional MOD43 check digit can enhance data security by allowing scanners to verify the integrity of the read data. The check digit is calculated based on the data string (excluding start/stop characters) using a weighted sum modulo 43.

Enable Check Digit

To enable the MOD43 check digit, set the Add Check Sum property to true in the Report Item Property view. The BIRT Report Engine automatically calculates the MOD43 check digit and appends it to the encoded data. The check digit is also displayed in the human readable interpretation (HRI) by default.



Hide Check Digit in HRI

You may want the check digit to be encoded (for scanner validation) but not displayed in the HRI text. This keeps the displayed text cleaner, especially when users expect to see only the original data.

Set ShowCheckSumChar = false in the Report Item Property view. The check digit will still be encoded in the barcode pattern and will be used by scanners for validation, but it will not appear in the text below the barcode.



Code 39 Start/Stop Characters Display

Code 39 uses the asterisk (*) as a fixed start character and stop character. These characters are automatically added to the encoded barcode pattern and should not be included in the Data property. However, you can control whether the asterisks appear in the human readable interpretation (HRI) text.

Show Asterisks in HRI

When Show Start Stop In Text is set to true (default), the HRI text is displayed with asterisks at the beginning and end. For example, if the data is ABC123, the HRI will show *ABC123*. This is the standard representation and helps users visually identify the barcode boundaries.

Hide Asterisks in HRI

When Show Start Stop In Text is set to false, the HRI text is displayed without the asterisks. For example, the HRI will show ABC123. This can be useful for reports where the asterisks are considered extraneous or where the displayed text must match a database value exactly.



Code 39 Barcode Dimension and Size Settings

All size parameters for Code 39 barcodes are set in the Report Item Property view. Proper dimension settings ensure that the barcode is scannable and fits within the report layout.

Unit of Measure (UOM)
Select the appropriate unit for all size related properties:
  • Pixel (default): Suitable for screen display and HTML output.
  • Inch: Suitable for printing on labels.
  • Centimeter: Suitable for metric printing requirements.


Module Width (X)
The X property defines the width of a narrow bar module. Wide bars are N times this value. The minimum X depends on your output medium and scanner capabilities. For screen display, a value of 2 - 4 pixels is common. For printing, 0.01 inch (0.254 mm) is a typical minimum. Smaller X values produce more compact barcodes but may be harder to scan.

Bar Height (Y)
The Y property defines the height of the barcode bars. Taller barcodes are easier to scan, especially for omnidirectional scanners. A typical value for screen display is 50 - 100 pixels. For printing, 0.5 inch is common.

Wide/Narrow Bar Ratio (N)
The N property defines the ratio of wide bars to narrow bars. Valid values range from 2.0 to 3.0 inclusive. The default is 2.0. Higher ratios (e.g., 2.5 or 3.0) make wide bars more distinct, which can improve scanning accuracy on low resolution printers or in noisy environments. However, higher ratios also increase the overall barcode width.

Intercharacter Gap (I)
The I property defines the space between two adjacent characters in the barcode. The value is a multiple of the narrow bar width X. The default is 1.0 (i.e., the gap equals the width of a narrow bar). Increasing the gap to 2.0 can improve character separation and readability, especially for long barcodes.

Quiet Zones (Margins)
The quiet zone is the blank area on the left and right sides of the barcode. It allows scanners to detect the start and stop patterns. For Code 39, the minimum recommended quiet zone is 10X. Set the LeftMargin and RightMargin properties accordingly. For example, if X = 2 pixels, set margins to at least 20 pixels. Top and bottom margins (TopMargin, BottomMargin) are less critical but should be at least 2X.

Resolution
The Resolution property sets the image resolution in dots per inch (DPI). For screen display, 96 DPI is typical. For high quality printing (e.g., thermal labels), 300 DPI is recommended. Higher resolutions produce larger image files but sharper bars.

Rotation
The Rotate property rotates the entire barcode image. Valid values are 0, 90, 180, and 270 degrees. This can be useful when the barcode needs to be placed in a narrow vertical space.



Customize Code 39 Bar and Space Appearance

You can adjust the bar width ratio and character spacing for better scanning and readability using the N and I properties described above. This section provides additional guidance on optimizing these settings for different output environments.


Wide/Narrow Bar Ratio (Property N)

The N property controls how distinguishable wide bars are from narrow bars. A ratio of 2.0 means wide bars are exactly twice as wide as narrow bars. A ratio of 3.0 means wide bars are three times as wide.
  • For high resolution printers (300 DPI or higher) and clean scanning environments, a ratio of 2.0 is sufficient.
  • For low resolution printers (e.g., thermal receipt printers) or environments with poor print quality, a ratio of 2.5 or 3.0 is recommended.
  • Ratios above 3.0 are not permitted by the Code 39 specification and may cause decoding errors.



Intercharacter Gap (Property I)

The I property defines the gap between characters. A larger gap makes it easier for scanners to differentiate between adjacent characters, especially in long barcodes or when the print quality is marginal.
  • The default value of 1.0 (gap equals narrow bar width) works well for most applications.
  • If you experience scanning failures with long barcodes (e.g., more than 20 characters), try increasing I to 2.0.
  • Values above 3.0 are rarely needed and may unnecessarily increase the barcode width.

After adjusting N and I, always test the barcode with the actual scanner hardware that will be used in production. Scanning performance can vary significantly between different scanner models and print media.



Note
When you increase N or I, the barcode becomes wider. This may affect the layout of your report, especially if the barcode is placed inside a table cell with a fixed width. Consider using a text element or a dynamic layout that can accommodate variable width barcodes.


Summary

This comprehensive guide has provided a complete, step by step workflow for generating Code 39 barcodes in BIRT reports for Eclipse Java projects. All Code 39 properties are configured in the Report Item Property view of the barcode report item. Using the BarcodeLib Code 39 BIRT Generator, you can customize Code 39 barcode encoding, check digit, dimensions, and display properties to meet your BIRT report's specific requirements, whether for inventory management, healthcare labeling, or government identification systems. The plugin is mature, redistributable as a single JAR, and requires no registration key.