Introduction of Code 128 Crystal Reports Barcode Generator
Code 128 barcode generation component for Crystal Report is one function of our mature .NET barcode component, which is capable of generating high quality Code 128 as Graphic images and being exported to other file formats without image distortion.
Besides Code 128 Barcode Control for Crystal Reports, OnBarcode.com provides 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 128 in .NET Crystal Reports Barcode SDK
This guide walks you through the process of generating Code 128 (a high-density linear barcode symbology) in Crystal Reports for .NET within ASP.NET and WinForms projects. It covers core implementation steps, character encoding, functional configurations, and dimension settings to ensure seamless integration with Crystal Reports components.
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 Code 128 barcode printed in the .rpt report, we will learn how to further customize Code 128 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 Code 128 barcode printed in the .rpt report, we will learn how to further customize Code 128 barcodes in Crystal Reports in the .NET application.
Code 128 Barcode Data Characters Encoding in Crystal Reports for .NET (C#)
Code 128 Data Character Set
Code 128 barcode (supported in Crystal Reports for .NET) supports the following data characters:
- All 128 Full ASCII characters defined in ISO/IEC 646.
- Extended ASCII characters (values 128-255 of ISO/IEC 8859-1) via Function Character (FNC4).
- 4 non-data function characters (FNC1-FNC4) for special operations.
- 4 code set selection characters (for switching between Code Sets A/B/C).
- 3 Start characters (one per code set) and 1 Stop character (mandatory for validation).
Code 128 Data Code Sets in C# for Crystal Reports
Code 128 barcode has three distinct code sets:
Key implementation notes for Crystal Reports:
The OnBarcode library auto-selects the optimal code set when
- Code Set A: Includes uppercase letters, numbers, and control characters.
- Code Set B: Includes lowercase letters, numbers, and standard symbols.
- Code Set C: Optimized for numeric data (encodes two digits per character).
Key implementation notes for Crystal Reports:
The OnBarcode library auto-selects the optimal code set when
BarcodeType.CODE128 is used (ideal for dynamic data in Crystal Reports Parameter fields).
To manually specify a code set (for fixed data in Crystal Reports Group Header/ Footer), set the Type property to:
BarcodeType.CODE128A (Code Set A)BarcodeType.CODE128B (Code Set B)BarcodeType.CODE128C (Code Set C)
Code 128 Function Characters in C# for Crystal Reports
Function Characters (FNC) in Code 128 enable special behavior in Crystal Reports barcode rendering:
- FNC1: Used for GS1 system compliance (e.g., GS1-128 in supply chain reports).
- FNC2: Enables message append (useful for multi-part data in Crystal Reports Group Header).
- FNC3: Instructs scanners to reprogram/initialize (rare in standard reports).
- FNC4: Encodes extended ASCII characters (critical for non-English data in Crystal Reports).
Note: The barcode library auto-encodes FNC characters - do not manually input them into Crystal Reports Parameter/Formula fields or C# codes, as this will corrupt the barcode.
Code 128 Check Digit in C# for Crystal Reports
- Code 128 requires a mandatory check digit (calculated via mod 103 algorithm).
- The check digit is not visible in the human-readable interpretation (HRI) and is not returned by scanners.
- In Crystal Reports integration: The
AddCheckSumproperty of theLinearclass is not applicable for Code 128 barcode - the library auto-calculates the check digit before the Stop character.
Code 128 Barcode Human Readable Interpretation (HRI) in Crystal Reports for .NET
HRI (text below/above the barcode) is critical for readability in Crystal Reports. It must not violate the barcode's quiet zone (mandatory for scannability).
By default, the Code 128 library will print the HRI (Code 128 text label) below the Code 128 symbol
By default, the Code 128 library will print the HRI (Code 128 text label) below the Code 128 symbol
- Set property
TextMarginto customize the space between barcode and text label (HRI) - Set property
TextFontto specify the text font name, style, and font size - Set property
TextFontto customize the text color
barcode.TextMargin = 10; barcode.TextFont = new Font("ocr-b", 22); barcode.TextColor = Color.Blue;
Note: To render HRI above the barcode in Crystal Reports, set
TextMargin to a negative value.
Ensure the Crystal Report's Page Header/Details section has sufficient space to avoid overlapping with other report elements.
Code 128 Barcode Dimension Settings in Crystal Reports for .NET (C#)
You can quickly customize the Code 128 image size in the report.
UOM: Unit of measure (PIXEL/CM/INCH, matches Crystal Reports report units).- Set the target Code 128 image width and height using property
BarcodeWidthandBarcodeHeight
barcode.UOM = UnitOfMeasure.INCH; barcode.BarcodeWidth = 1; barcode.BarcodeHeight = 0.5f;
You can also further customize Code 128 dimensions to fit Crystal Reports layout (Page Header/Footer, Details section) using the following 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 specifiedXvalue for bar module width, andYvalue for bar module height.X: Width of narrow elements (minimum width defined by application specs).Y: Bar height (ensure it fits within Crystal Reports control bounds).Margins (LeftMargin, RightMargin, TopMargin, BottomMargin): Quiet zone (minimum 10X to comply with barcode standards).
Common Asked Questions
What is the barcode Code 128 text code?
Code 128 barcode is a high-density 1d barcode symbology, which encodes digits, letters, control characters, and full ASCII 128 characters.
Using Crystal Reports for .NET barcode generator library, you can create, print, insert Code 128 barcodes in Crystal report table cells, preview the Code 128 barcodes in Crystal
report viewer in .NET ASP.NET Core, Windows Forms projects.
What is Code 128 barcode maximum length?
There is no specific definition about Code 128 barcode maximum number of characters in Code 128 ISO 15417 standard.
However some Code 128 standards will provide the limits. GS1-128 has limits the maximum length of Code 128 data to 48 characters.
Using .NET Crystal Reports Barcode library, you will encode and generate ISO standard Code 128 and application approved Code 128 barcodes, such as GS1-128 in Crystal reports in .NET web and Windows applications.
However some Code 128 standards will provide the limits. GS1-128 has limits the maximum length of Code 128 data to 48 characters.
Using .NET Crystal Reports Barcode library, you will encode and generate ISO standard Code 128 and application approved Code 128 barcodes, such as GS1-128 in Crystal reports in .NET web and Windows applications.
What is the check digit for code 128?
Code 128 barcode contains a last digit of mandatory check digit (checksum) character, which is based on module 103 (mod 103).
Code 128 check digit will not be displayed in the Code 128 human readable text and will not be returned by the Code 128 barcode scanners.
Using Crystal Reports for .NET barcode freeware, the generator software will automatically calculate the check character and insert into the Code 128 barcode
in Visual Studio .NET Crystal reports ASP.NET Core, Windows Forms projects.
What is Code 128 barcode commonly used for?
Code 128 barcode is a common linear barcode type used in:
- Food and non-food industries
- Shipping and packing industry
- Health, public sector and government bodies
Is Code 128 barcode better than Code 39?
Both Code 128 and Code 39 are popular 1d barcode symbologies.
Code 128 is more compact than Code 39, supporting more data to be encoded in a smaller space.
.NET Crystal Reports Barcode library allows C#/VB.NET developers to encoding and printing both Code 128 and Code 39
using Microsoft Visual Studio with the Crystal Report Designer extension.
How to scan, read Code 128 barcodes?
To scan, read and decode the Code 128 barcodes in the Crystal Reports,
you can download and install OnBarcode free Code 128 barcode scanner software, or use barcode scanner device, or
smart phone (iOS or Android) camera with 3rd party barcode apps installed.