JasperReports Code 39 Generator Library

Java Code 39 Barcode Generator Library to create, print Code 39 images in JasperReports, iReport reports

Code 39 for iReport plugin generate, create Code 39 barcode in iReport Jasper Reports

  • Easy to generate Code 39 barcodes in iReport reports
  • Simple to redistribute iReport Code 39 barcode library (jar).
  • No registration key. No activation code.
  • Generating high quality Code 39 Bar Code images in GIF format
  • Completely developed in NETBeans iReport Custom Extended Report Item framework.
  • Mature iReport Code39 barcode generation plugin using Java Barcode Generator library
Here we will learn how to generate, embed, print Code 39 barcodes within JasperReport reports using Jaspersoft Studio (official Eclipse-based report designer) or iReport Designer (legacy Swing-based report designer).

Here's a list summarizing the full content:
  • Quick steps to insert and generate Code 39 as a Barcode Component in a JRXML (XML source template file) using Jaspersoft Studio or iReport Designer, including basic configuration and export.
  • Detailed explanations of Code 39's supported character sets (standard and Full ASCII modes), including how to configure each mode in the Report Item Property panel.
  • Configuration of Code 39 check digit (MOD43), including how to enable/disable it and control its visibility in the Human Readable Interpretation (HRI) text.
  • Management of Code 39 start/stop characters (*), including how to show or hide them in the HRI text via report properties.
  • Customization of Code 39 dimension settings (unit of measure, bar width, height, wide/narrow ratio, intercharacter gap, margins) in JasperReport reports, aligned with JasperReport's Formatting & Style terms.
  • Advanced customization of Code 39's wide/narrow bar ratio (N) and intercharacter gap (I) to meet specific report design requirements.

JasperReport Barcode Code 39 Generator Introduction

Top
iReport Barcode is a NETBeans iReport Custom Extended Report Item which helps you easily generate and print high quality 1D (linear) and 2D (matrix) barcodes in your iReport reports.

Barcode Code-39 Introduction

Code 39 (also known as "USS Code 39", "Code 3/9", "Code 3 of 9", "USD-3", "Alpha39", "Type 39") is a barcode symbology that can encode uppercase letters (A through Z), digits (0 through 9) and a handful of special characters like the $ sign.



Code 39 is restricted to 44 characters. In Full ASCII Code 39 Symbols 0-9, A-Z, "." ,and "-" are the same as their representations in Code 39. Lower case letters, additional punctuation characters and control characters are represented by sequences of two characters of Code 39.

iReport Code-39 Generator - Valid Data Scope

  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • Uppercase letters (A - Z)
  • - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus)
  • iReport Code 39 Extension Generator supports all 128 ASCII characters

Code 39 Generators

OnBarcode provides several Code 39 Generator components and software, including Code 39 Generator .NET, Code 39 Generator Java, Code 39 Generator C#, Code 39 Generator VB.NET, Code 39 Generator.






How to Generate Code 39 Barcode in JasperReport?

Top
Here are simple steps to create a Code 39 barcode in iReport. View details here: tutorial to generate and print barcodes in iReport reprts.

One more guide for you to stream Code 39 barcodes in iReport using Java Barcode Generator buildin Servlet web application.
  1. Create a new report, and add barcode.jar to report classpath from the downloaded trial package
  2. Drag an image item in Palette to report
  3. Click "Cancel" button, in "Select an image file" window
  4. Right click on the image and edit its "Properties", and set property "Expression Class" to "net.sf.jasperreports.engine.JRRenderable";
  5. To input Code 39 barcode data manually, set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer(
    com.onbarcode.barcode.jasper.BarcodeGenerator.draw(2, "12345", "", "X=2&Y=60"))
    "
  6. To print Code 39 with data from database, please set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer(
    com.onbarcode.barcode.jasper.BarcodeGenerator.draw(2, $F{data field} + "", "", "X=2&Y=60"))
    ";

    BarcodeGenerator.draw method accepts 4 parameters:
    the second is the barcode data to encode, in String,
    the last is the barcode settings String. More details about barcode settings string, please check the Code 39 property table below




Code 39 Barcode Data Characters Encoding in JasperReport Reports

Code 39 barcodes support two main encoding modes: Standard Mode and Full ASCII Mode. Both modes are configurable in the Report Item Property panel of Jaspersoft Studio or iReport Designer.


Code 39 Standard Mode

Code 39 Standard Mode supports 43 characters, making it ideal for basic alphanumeric encoding. Here's how to configure it in your JasperReport report:

Supported characters in Standard Mode:
  • Numeric digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • Uppercase letters (A - Z)
  • Special characters: - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus)
  • Start/Stop character (asterisk *—automatically added by the JasperReports Library)
Configuration steps:

  • Select the Code 39 Barcode Component in your JRXML template.
  • Open the Report Item Property panel and set the "Barcode Type" to "CODE39" (this enables Standard Mode).
  • Enter the data to encode in the "Data" field (static text or dynamic Expression referencing a Field/Parameter).
  • Save the JRXML template to apply the settings.


Example configuration:
  • Barcode Type: CODE39
  • Data: "ABC-12345" (static) or $F{StandardCode39Data} (dynamic)



Note: Do not include the start/stop character (*) in the "Data" field. The JasperReports Barcode Library automatically adds it to ensure scannability.


Code 39 Full ASCII Mode

Code 39 Full ASCII Mode supports the full 128-character ASCII set (per ISO 646 IRV), including lowercase letters, additional special characters, and control characters. This mode is ideal for advanced encoding needs. Here's how to configure it:

Configuration steps:
  • Select the Code 39 Barcode Component in your JRXML template.
  • Open the Report Item Property panel and set the "Barcode Type" to "CODE39EX" (this enables Full ASCII Mode).
  • Enter the data to encode in the "Data" field—this can include lowercase letters (e.g., "abc-12345") and other ASCII characters.
  • Save the JRXML template to apply the settings.


Example configuration:
  • Barcode Type: CODE39EX
  • Data: "abc-12345" (static) or $F{FullAsciiCode39Data} (dynamic)



Note: Ensure your barcode scanner supports Full ASCII Mode to correctly decode the data. Some older scanners may only support Standard Mode.


Code 39 Barcode Check Digit

Code 39 does not include a check digit by default. However, for enhanced data security, you can enable a modulo 43 (MOD43) check digit. This setting is configured in the Report Item Property panel:

To enable the check digit:
  • Select the Code 39 Barcode Component and open the Report Item Property panel.
  • Locate the "AddCheckSum" property and set it to "true".
  • Save the JRXML template. The JasperReport Barcode Library will automatically calculate and append the MOD43 check digit.
Example configuration:
  • Barcode Type: CODE39
  • Data: "ABC-123"
  • AddCheckSum: true



Note: The check digit is calculated based on the input data and is not part of the original "Data" field. It is added automatically by the JasperReport Barcode Library.


Hide Code 39 Check Digit in HRI

You can enable the check digit while hiding it from the Human Readable Interpretation (HRI). The text displayed below/above the barcode. This is configured in the Report Item Property panel:

Steps to hide the check digit in HRI:
  • Ensure "AddCheckSum" is set to "true" (as shown in Section 2.3).
  • Locate the "ShowCheckSumChar" property in the Report Item Property panel and set it to "false".
  • Save the JRXML template. The check digit will be encoded in the barcode but not displayed in the HRI text.



Note: Hiding the check digit in HRI is useful for maintaining a clean report design while still ensuring data integrity via the check digit.


Code 39 Barcode Start/Stop Characters

Code 39 uses the asterisk (*) as its start and stop characters. These characters are required for scanning but should not be included in the "Data" field. You can control their visibility in the HRI text via the Report Item Property panel:
  • The start/stop characters (*) are automatically added by the JasperReport Barcode Library. Do not include them in the "Data" field.
  • To show or hide the start/stop characters in the HRI text, use the "ShowStartStopInText" property.



Note: Hiding the start/stop characters in HRI is recommended for most report designs, as the asterisks are not part of the actual data and can clutter the layout.


Code 39 Barcode Dimension Size in JasperReport Reports

You can fully customize the dimension size of Code 39 barcodes in JasperReport reports, including unit of measure, bar width, height, wide/narrow ratio, intercharacter gap, and margins.

The following settings are available in the Report Item Property panel to customize Code 39 dimensions.
  • UOM (Unit of Measure): Select the unit for dimension settings: PIXEL, CM, or INCH. Default is PIXEL.
  • X: Width of the narrow bar module (the smallest unit of the barcode). The minimum width is defined by your application’s specifications.
  • Y: Height of the barcode module (the vertical length of the bars).
  • N: Wide/narrow bar ratio. Valid values range from 2.0 to 3.0 (inclusive). Default is 2.0.
  • I: Width of the intercharacter gap (space between two barcode characters).

    Minimum gap is equal to X (narrow bar width).

    Maximum gap: For X < 0.287mm, it is 5.3X; for X ≥ 0.287mm, it is 1.52mm or 3X (whichever is greater).
  • LeftMargin, RightMargin: Quiet zone (empty space) around the Code 39. The minimum width of each margin is 10X (10 times the narrow bar width X).
  • TopMargin, BottomMargin: Vertical spacing around the barcode (optional, but recommended to avoid overlapping with other report elements).



Customize Code 39 Barcode Features in JasperReport Reports

You can further customize Code 39 barcodes in JasperReport reports by adjusting the wide/narrow bar ratio (N) and intercharacter gap (I). These settings are critical for optimizing barcode readability and fitting the barcode into your report layout.


Code 39 Wide Bar vs Narrow Bar Ratio (N)

The ratio (N) defines the relationship between the width of wide bars and narrow bars. This setting directly impacts barcode scannability and appearance:
  • Valid values: 2.0 to 3.0 (inclusive). Default is 2.0.
  • A ratio of 2.0 means wide bars are twice as wide as narrow bars.
  • A ratio of 3.0 means wide bars are three times as wide as narrow bars.



Note: Choose a ratio based on your scanning environment. A higher ratio (e.g., 3.0) is more readable for low-resolution printers or scanners.


Code 39 Intercharacter Space (I)

The intercharacter space (I) is the gap between two consecutive barcode characters. It is a multiple of the narrow bar width (X) and impacts barcode readability:
  • Default value: 1.0f (gap equals the narrow bar width X).
  • The gap must be at least X (minimum) and follow the maximum gap rules outlined in Section 3.1.



Note: Increasing the intercharacter gap (I) can improve readability but will increase the overall width of the barcode. Ensure the barcode fits within your report's layout.

JasperReport Barcode Code39 Generator - Property Settings

Top
Category Properties Value Comments
Basic Property: Data Type: expression
Default: ""
  • If you encode the barcode data text directly, the text string should be around by " " ", such as "12345"

  • If you encode the barcode data from dataset, input the expression, such as row["CUSTOMERNUMBER"]
Barcode value to encode.

Code 39 Valid Data Char Set:

  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

  • Uppercase letters (A - Z)

  • - (Dash), $ (Dollar), % (Percentage), (Space), . (Point), / (Slash), + (Plus)


Code 39 extension Valid Data Char Set:

  • all 128 ASCII characters

Property: Add CheckSum Char Type: boolean
Default: false
Add CheckSum Char property is optional. Modulo 43 will be applied, if addCheckSum property is true.
 
Code 39
Special
Property: Code 39 extension Type: boolean
Default: false
If you want to encode any 128 ASCII characters, extension must be true.
Property: I Type: float
Default: 1.0f
The space between 2 characters in code 39. This a multiple of X.
Property: N Type: float
Default: 2.0f
Wide/narrow ratio, 2.0 - 3.0 inclusive, default is 2.
Property: Code39 Show Start Stop Chars Type: boolean
Default: true
If true, display a * in the beginning and end of barcode text
Property: Process Tilde Type: boolean
Default: false
Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data.

  • 1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); ASCII character '~' is presented by ~126
    Strings from "~256" to "~299" are unused
 
Barcode
Size
Related
Property: Unit of Measure Type: int
Default: 0 (pixel)
Unit of meature for all size related settings in the library.
Valid values: 0: pixel; 1: inch; 2: cm.
Property: X Type: float
Default: 1
Width of barcode bar module (narrow bar), default is 1 pixel
Property: Y Type: float
Default: 30
Height of barcode bar module, default is 30 pixel
Property: Left Margin Type: float
Default: 0
Barcode image left margin size.
Property: Right Margin Type: float
Default: 0
Barcode image right margin size.
Property: Top Margin Type: float
Default: 0
Barcode image top margin size.
Property: Bottom Type: float
Default: 0
Barcode image bottom margin size.
Property: Resolution (in dpi) Type: int
Default: 72
Barcode image resolution in DPI (Dots per inch).
Property: Rotate Type: int
Default: 0 (rotate angle in 0 degree)
Valid values:

  • 0 (rotate angle in 0 degree)
  • 90 (rotate angle in 90 degree)
  • 180 (rotate angle in 180 degree)
  • 270 (rotate angle in 270 degree)
 
Font
Style
Property: Show Text Type: boolean
Default: true
If true, display barcode data text under the barcode, otherwise do not display.
Property: Text Font Size Type: int
Default: 11
Barcode text font size.
Property: Text Margin Type: float
Default: 6
Space between barcode and barcode data text, default is 6 pixels


Summary

Here we have explained step-by-step approach to generating and customizing Code 39 barcodes in JasperReport reports using Jaspersoft Studio or iReport Designer. We covered all key aspects, including basic generation, data encoding (Standard and Full ASCII modes), check digit configuration, start/stop character management, dimension customization, and advanced settings for wide/narrow ratio and intercharacter gap.







































Start with free trial package:








































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.