Introduction of Code 39 Crystal Reports Barcode Generator
Code 39 barcode generator for Crystal Report is one function of our mature .NET barcode component, which is easy to integrate into .NET Crystal Report and generate high quality Code 39 dynamically.
OnBarcode.com provides not only Code 39 Barcode Control for Crystal Reports, but also other linear and 2D barcode generator for Crystal Report
with detailed online
how-to guide:
- Linear Barcodes in Crystal Reports: Code 39, Code 128, EAN-8, EAN-13, GS1 128, UPC-A, UPC-E, Interleaved 2 of 5, Identcode, ISBN, ISSN, ITF-14, Leitcode, MSI Plessey, OneCode, Planet, Postnet, RM4SCC, etc
- 2D Barcodes in Crystal Reports: including QR Code, Data Matrix, PDF-417
How to Generate Code 39 barcode in .NET Using Crystal Reports Barcode SDK
This developer guide page offers a detailed, step-by-step approach to printing Code 39 (a discrete, variable-length linear barcode symbology) in Crystal Reports for .NET within ASP.NET and Windows Forms web and desktop (.net framework) applications.
It shows how to insert Code 39 in report designer, customize and print in report viewer, Code 39 data encoding modes, check digit configuration, dimension settings, and advanced customization to ensure seamless integration with Crystal Reports components and compliance with industry standards.
It shows how to insert Code 39 in report designer, customize and print in report viewer, Code 39 data encoding modes, check digit configuration, dimension settings, and advanced customization to ensure seamless integration with Crystal Reports components and compliance with industry standards.
Preparation
We have two step by step tutorials to create new ASP.NET and Windows Forms .net framework projects to print barcodes in .rpt report file in .NET application.
After you have created a new ASP.NET or Windows Forms project with the first barcode printed in the .rpt report, we will learn how to generate and customize Code 3 of 9 linear barcodes in Crystal Reports in the .NET application.
- Print barcode in Crystal Reports in ASP.NET web application
- Print barcode in Crystal Reports in Windows Forms application
After you have created a new ASP.NET or Windows Forms project with the first barcode printed in the .rpt report, we will learn how to generate and customize Code 3 of 9 linear barcodes in Crystal Reports in the .NET application.
Print Code 39 barcodes in Crystal Report
Here we will start to modify the tutorial project to create, insert Code 39 1d barcode in the Crystal Reports report designer and print the Code 39 barcode in the report viewer.
In Visual Studio IDE,
After successfully generating the Code 39 barcodes in Crystal Reports in your C# ASP.NET/WinForms project, we will further customize the Code 39 in the report.
In Visual Studio IDE,
- For ASP.NET project, open file
Default.aspx.cs - For Windows Forms project, open file
Form1.cs
- Change barcode type from Code 128 to Code 39.
BarcodeType.CODE39; - Assign the target data string to the
Dataproperty of the barcode object (map this to a Crystal Reports Parameter field for dynamic data). - Call method
drawBarcodeAsBytes()to generate the Code 39 barcode as a byte array and store the Code 39 barcode image as a PNG image file in byte[] object (the standard format for Crystal Reports image controls in .rpt files).
linear.Type = BarcodeType.CODE39;
After successfully generating the Code 39 barcodes in Crystal Reports in your C# ASP.NET/WinForms project, we will further customize the Code 39 in the report.
- Code 39 data encoding, standard and extended Code 39
- Code 39 barcode dimension width and height configuration
- More Code 39 options, such as wide/narrow bar ratio, inter-character gap
Code 39 Barcode Data Characters Encoding in Crystal Reports for .NET (C#)
Here we will learn what characters Code 39 are able to encode.
Code 39 Standard Mode
Code 39 standard mode (supported in Crystal Reports for .NET) supports 43 characters:
To use standard mode in Crystal Reports:
- Numeric digits (0-9).
- Uppercase letters (A-Z).
- Special characters: -, $, %, space, ., /, +.
- Start/Stop character (*, auto-added by the library. Do not include in
Dataproperty).
To use standard mode in Crystal Reports:
- Enter the characters into property
Data.
Note: Standard mode only supports uppercase letters. Lowercase input will not encode correctly, you need choose Code 39 extension mode to encode lowercase characters.
Code 39 Full ASCII Mode (extension mode)
Code 39 Full ASCII mode encodes the full 128 ASCII character set (per ISO 646 IRV), including lowercase letters. To enable this mode:
- Change barcode type to
BarcodeType.CODE39EX.
linear.Type = BarcodeType.CODE39EX;
Code 39 Check Digit Configuration
- Code 39 does not include a check digit by default (suitable for low-risk Crystal Reports use cases).
- For enhanced data security (e.g. inventory reports), enable the MOD43 check digit via the
AddCheckSumproperty.
linear.AddCheckSum = true;
In the Code 39 image below, the character
J is the check character.
Hide Check Digit in Human Readable Interpretation (HRI)
You can also enable the Code 39 check character, but hide it in the Code 39 HRI (text label) in Crystal Report.
- Set property
AddCheckSumto true, to enable Code 39 check character - Set property
ShowCheckSumCharto false, to hide the check character
Linear linear = new Linear(); linear.Data = "Code-39"; linear.Type = BarcodeType.CODE39EX; linear.AddCheckSum = true; linear.ShowCheckSumChar = false;
Code 39 Start/Stop Characters
Code 39 uses
* as Start/Stop characters (auto-added by the library). To hide these characters in the HRI:
linear.ShowStartStopInText = false;
Note: The * character must not be included in the
Data property. This will corrupt the barcode (enforce via Crystal Reports Filtering).
Code 39 Barcode Dimension Settings for Crystal Reports (C#)
You can easily generate Code 39 with specified barcode image width and height in Crystal Reports report template.
You can also further customize Code 39 dimensions to fit Crystal Reports layout (Header/Footer/Details sections) using these properties:
- Property
UOM: Unit of measure (PIXEL/CM/INCH, matches Crystal Reports report units). - Property
BarcodeWidthandBarcodeHeight: Set the Code 39 image with specified width and height.
Linear linear = new Linear(); linear.Data = "CODE-39"; linear.Type = BarcodeType.CODE39; linear.UOM = UnitOfMeasure.INCH; linear.BarcodeWidth = 3; linear.BarcodeHeight = 1;
You can also further customize Code 39 dimensions to fit Crystal Reports layout (Header/Footer/Details sections) using these properties:
AutoResize: If true, the barcode library will choose the maximum bar module width and height values. If false, the barcode library will use the developer specified X value for bar module width, and Y value for bar module height.X: Narrow element width (minimum defined by application specs).Y: Bar module height (ensure it fits Crystal Reports PictureBox bounds).N: Wide/narrow ratio (2.0–3.0 inclusive, default: 2.0).I: Intercharacter gap (minimum = X; maximum depends on X value).- LeftMargin/RightMargin: Quiet zone (minimum 10X to avoid scanning errors).
How to Generate EAN-13 in .NET Using Crystal Reports Barcode Control
Wide/Narrow Ratio (N)
Adjust the wide/narrow bar ratio to optimize scannability in Crystal Reports:
- Use property
Nto customize the Code 39 wide/narrow bar ratio.
The valid value should be between2.0fto3.0f.
The default value is2.0f
Linear barcode = new Linear(); barcode.Data = "CODE-39"; barcode.Type = BarcodeType.CODE39; barcode.N = 3;
Note: Incorrect N values (outside 2.0 - 3.0) will produce unreadable barcodes. Validate in the Development environment before Deployment to Crystal Reports Server.
Intercharacter Gap (I)
Modify the gap between characters:
- Use property
Ito customize the space between two character bar modules, and it is a multiple ofX(narrow bar module width).
The minimum gap is equal to X
The maximum: for X < 0.287mm, is 5.3X; for X >= 0.287mm, is 1.52mm or 3X, whichever is greater.
The default value is1.0f
Linear barcode = new Linear(); barcode.Data = "CODE-39"; barcode.Type = BarcodeType.CODE39; barcode.I = 5;
Note: Excessively large
I value
will produce unreadable Code 39 barcodes. Use barcode scanner to verify the printed Code 39 barcodes before deployment to Crystal Reports Server.
Common Asked Questions
What is the use of Code 39 barcode?
Code 39, also known as Code 3 of 9, is the first barcode symbology to encode both numbers and letters (Upper case letters only). It is most commonly used in
the inventory, government, military, automotive and electronics industries.
Using Crystal Reports for .NET barcode generator library, you can create, print, and insert Code 39 barcodes in Crystal report designer, and preview them in Crystal report viewer using Visual Studio .NET. You will easiy enable Code 39 barcode generation functions in Crystal reports in ASP.NET Core, Windows Forms applications.
Using Crystal Reports for .NET barcode generator library, you can create, print, and insert Code 39 barcodes in Crystal report designer, and preview them in Crystal report viewer using Visual Studio .NET. You will easiy enable Code 39 barcode generation functions in Crystal reports in ASP.NET Core, Windows Forms applications.
What is the difference between barcode 39 and barcode 93?
Bath Code 39 and Code 93 are linear (1d) barcode formats.
Code 93 is an updated version of Code 39. Code 93 is a higher-density barcode type compared to Code 39.
Using .NET Crystal Reports barcode generator software, you can create both Code 39 and Code 93 in Crystal reports.
What is the difference between Code 39 and Code 128 barcodes?
Bath Code 39 and Code 128 are linear (1d) barcode symbologies.
Code 128 requires a compulsory checksum digit. If the Code 128 barcode is damaged, it may still be scannable. Code 39 checksum is optional.
If the Code 39 barcode without checksum is damaged, it won't be scannable.
Using Crystal Reports for .NET barcode generator software, you can create both Code 39 and Code 93 in Crystal reports in Visual Studio ASP.NET, MVC, Windows Forms projects.
Can Code 39 barcode encode lowercase letters in Crystal reports?
Code 39 barcode standard version does not support lowercase letters encoding, it supports uppercase letters only.
However the Code 39 extended version does. OnBarcode Crystal Reports for .NET Barcode Generator software does support both Code 39 standard and extend versions.
You can quickly draw, print and insert Code 39 with uppcase and lowercase letters in Crystal reports.
What is the minimum size for Code 39 barcode?
The recommended minimum height for Code 39 manual scanning is 5.0mm or 15 % of Code 39 width (excluding quiet zones), whichever is greater.
Code 39 barcodes need meet the following barcode dimension size requirements.
Code 39 barcodes need meet the following barcode dimension size requirements.
- X (X): the mimumum bar width (X module) is defined by the application specification.
- Y: the minimum height is 5.0mm or 15% of symbol width (excluding quiet zones), whichever is greater.
What is the ratio of narrow to wide bars in Code 39 barcode?
The valid wide bar vs narrow bar ratio of Code 39 barcode is from 2 to 3 inclusive. By default, the Crystal Reports for .NET barcode software will apply bar ratio as 3.
You can print and customize the Code 39 in Crystal report through property
N in Crystal report item property settings in Visual Studio .NET.