How to create, print Code 128 in .NET RDLC reports
The Code 128 Barcode Generator for RDLC is an advanced barcode generation component that enables printing of Code 128 barcodes within client report definition (RDLC) files for .NET projects. The integrated Code 128 control DLL renders high quality barcode graphics directly in reports. Generated Code 128 barcodes are fully adjustable using C#.NET or VB.NET, allowing precise control over symbology parameters.
How to Generate Code 128 Using the RDLC Barcode Generator
This guide provides instructions for generating Code 128 linear barcodes within RDLC Local Reports using C#. The approach is tailored for ASP.NET (including ASP.NET Framework and MVC) and Windows Forms (.NET Framework) projects integrated with the ReportViewer Control.
Two step by step tutorials are available for creating new ASP.NET and Windows Forms .NET Framework projects to print barcodes in .rdlc report files:
Print barcode in RDLC local reports in ASP.NET web applications
Print barcode in RDLC local reports in Windows Forms applications
After creating a new ASP.NET or Windows Forms project with the first Code 128 barcode printed in the .rdlc report viewer, further customization of Code 128 barcodes in RDLC local reports can be performed.
Code 128 Barcode Data Encoding in RDLC Local Reports (C#)
Code 128 Supported Character Sets
Code 128 barcodes in RDLC reports support the following character sets, aligned with global barcode standards:
All 128 full ASCII characters (per ISO/IEC 646)
Extended ASCII characters (128–255, ISO/IEC 8859-1) via Function Character 4 (FNC4)
Four non data function characters (FNC1 - FNC4)
Four code set selection characters
Three start characters and one stop character (automatically added by the library)
Code 128 Data Code Sets Configuration
Code 128 uses three distinct code sets (A, B, C), each optimized for specific data types in RDLC reports:
Code Set A: Alphanumeric characters, control characters, and special symbols
Code Set B: Alphanumeric characters, lowercase letters, and common symbols
Code Set C: Numeric data (efficient for long numeric strings in RDLC)
Using the barcode type BarcodeType.CODE128, the RDLC barcode generation library automatically selects the optimal code set for RDLC. Manual selection can be performed by choosing one of the following types:
BarcodeType.CODE128A
BarcodeType.CODE128B
BarcodeType.CODE128C
Code 128 Function Characters (FNC) for RDLC
Function characters (FNC) enable advanced functionality in Code 128 barcodes for RDLC reports:
FNC1: For GS1 system compliance (critical for logistics and retail RDLC reports)
FNC2: For message append (splitting large data across multiple RDLC barcodes)
FNC3: For barcode reader reprogramming (rare in standard RDLC use cases)
FNC4: For extended ASCII encoding (128 - 255, ISO/IEC 8859-1)
Note: Manual input of FNC characters is not required. The RDLC barcode library automatically encodes them based on the data and the RDLC use case (e.g., GS1 data triggers FNC1 automatically).
Code 128 Check Digit Configuration
Code 128 requires a mandatory MOD 103 check digit, which is automatically generated by the library for RDLC compliance:
The check digit is not displayed in the human readable interpretation (HRI).
The AddCheckSum property is not applicable to Code 128; the library ignores this setting.
The check digit is always appended before the stop character, ensuring data integrity in RDLC.
Note: Do not manually add start or stop characters to the Data property. The barcode library automatically adds them. Manual inclusion will cause encoding errors in RDLC.
Code 128 Barcode Human Readable Interpretation (HRI) for RDLC (C#)
HRI (the text displayed below or above the barcode) is required for Code 128 in RDLC reports and must not violate quiet zone boundaries. HRI is rendered below the Code 128 barcode by default for RDLC.
TextMargin: Sets the space between the barcode and the text label.
TextFont: Specifies the font family and size for the Code 128 text label.
TextColor: Defines the text color.
Note: Verify in the RDLC report that the HRI is visible and does not overlap with quiet zones or other report elements (e.g., TextBox, Line). Excessively negative TextMargin values may cause the HRI to be cut off by the RDLC barcode Image report item. Test with sample data before final implementation.
Code 128 Barcode Dimension Settings for RDLC Local Reports (C#)
The RDLC barcode library uses the following properties to customize Code 128 barcode dimensions in local reports for C# ASP.NET, WPF, and WinForms projects:
UOM: Unit of measure (PIXEL, CM, INCH)
BarcodeWidth: Code 128 barcode image width
BarcodeHeight: Code 128 barcode image height
Further Customize Code 128 Dimensions for RDLC Print Layout Compliance
The following properties provide additional control:
AutoResize: If true, the barcode library automatically selects the maximum bar module width and height values. If false, the library uses developer specified values for X (narrow element width) and Y (bar module height).
X: Width of the narrow element (minimum value defined by application specifications).
Y: Bar module height.
LeftMargin / RightMargin / TopMargin / BottomMargin: Quiet zone (minimum width = 10X for RDLC compliance).
Note: Confirm in the RDLC report that the Code 128 barcode dimensions match the configured values and that no stretching occurs within the Image report item. For high resolution RDLC printing (300 DPI), set the Resolution property to align with print layout settings to avoid blurry barcodes.
Summary
The core workflow for generating Code 128 barcodes in an RDLC Local Report is as follows:
Initialize a Linear barcode object with the barcode type set to BarcodeType.CODE128.
Configure Code 128 encoding and code set selection.
Generate the barcode byte stream.
Bind the byte stream to an RDLC Image report item.
Render the report through the ReportViewer Control (ASP.NET / Windows Forms).
Key Code 128 Customization Properties for RDLC include:
Auto or manual code set selection (A, B, or C).
Mandatory MOD 103 check digit (auto generated).
HRI positioning (below the barcode with configurable TextMargin).
Critical RDLC compliance rules encompass:
Quiet zones (minimum 10X).
GS1 formatting for industry use cases.
Alignment of barcode dimensions with the RDLC Image report item size.
These settings must align with the properties of the RDLC Image report item to ensure accurate rendering.