Enjoy free 6-month Premium Support & free 12-month Software Update with a purchased Crystal Reports Barcode Generator Control License
The Data Matrix Barcode Control for Crystal Reports is designed to generate high-quality Data Matrix barcode symbols within Crystal Report documents.
Data Matrix barcodes can be preserved in exported file formats such as PDF, Word, Excel, and Rich Text Format (RTF).
This guide provides a structured, step-by-step methodology for generating Data Matrix (a 2D matrix barcode symbology) within Crystal Reports for .NET across ASP.NET, WinForms, and WPF projects. It covers core implementation, data encoding, dimension configuration, color and image settings, and advanced features to ensure seamless integration with Crystal Reports components and compliance with industry standards.
Crystal Reports Barcode Generator Control SDK Supported Barcodes
2D Barcode Images Supported by Crystal Reports Barcode Generator Control: Data Matrix, QR-Code, and PDF-417;
Linear Barcode Images Supported by Crystal Reports Barcode Generator Control: Codabar, Code 11, Code 2 of 5, Code 39, Code 93, Code 128, EAN-8, EAN-13, EAN-128, Interleaved 2 of 5, ITF-14, UPC-A, UPC-E, etc.
BarcodeLib.com .NET Crystal Reports Barcode Generator SDK can fully integrate into .NET Framework IDEs. You can easily generate and add Data Matrix barcode images on your Crystal Reports through property settings or using C# / VB class library. This barcode component supports dynamic data connection to virtually data source to build user-defined Crystal Report.
Create & Add Data Matrix Barcode on ASP.NET Crystal Reports Application
Create a new ASP.NET website.
Choose "ASP.NET Crystal Reports Web Site" as the template and named the project as "BarcodeforCrystalReportsWebSite".
Add a new item "Crystal Report" to your project.
Add a new item "Crystal Report" to the project and name it as "CustomerReport.rpt". view image
Select "Mail Label" in the pop-up window and click "OK". view image
In "Mailing Labels Report Creation Wizard", click "Create New Connection", and expand "ADO.NET". view image
In "ADO.NET" form, choose "CustomerDataSet.xsd" file in your downloaded package, and click "Finish". view image
In "Mailing Labels Report Creation Wizard", add table "Customer" under "ADO.NET" to selected table. And click "Next". view image
Add all three fields "ID", "CustomerId", "CustomerName" to "Fields to Display:", then click "Next". view image
Select default label "Return Address (Avery 5267)", and click "Finish".
Now you can view the report template and find that field "Barcode" not in the report template. view image
Now, please re-arrange the report template. view image
Drag field "Barcode" to the report template, right click "Barcode" object and choose "Format Object" menu. view image
In "Format Editor" form, check "Can Grow" property. view image
Drag a "Crystal Report Viewer" to the "Default.aspx".
Add a reference to BarcodeLib.Barcode.CrystalReports.dll.
Copy the following C# code to the "Default.aspx.cs" file.
using System.Data.OleDb; using System.Drawing.Imaging; using BarcodeLib.Barcode.CrystalReports; using BarcodeLib.Barcode;
protectedvoid Page_Load(object sender, EventArgs e) { // Create the database connection. Please change to correct data file (BarcodeDemoData.mdb) path. OleDbConnection aConnection = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:/BarcodeLib_NETBarcode_Trial/ReportingData/BarcodeDemoData.mdb"); aConnection.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter("SELECT * FROM Customer", aConnection); DataSet ds = new DataSet(); dataAdapter.Fill(ds);
// Add the Barcode column to the DataSet ds.Tables[0].Columns.Add(new DataColumn("Barcode", typeof(byte[])));
// Use DataMatrixCrystal for Data Matrix DataMatrixCrystal barcode = new DataMatrixCrystal();
Data Matrix Barcode Data Character Encoding in Crystal Reports for .NET
Valid Encoding Character Set
Data Matrix (supported in Crystal Reports for .NET) supports the following character sets:
Full ASCII table (all 128 characters defined in ISO/IEC 646)
Extended ASCII (ISO 8859-1 values 128 - 255)
Other character sets (Arabic, Cyrillic, Greek, Hebrew) via the Extended Channel Interpretation (ECI) protocol, compatible with Crystal Reports data source binding
Maximum Data Length
Data Matrix data capacity varies by encoding mode, which is critical for Crystal Reports filtering and grouping of large datasets:
Alphanumeric data: Up to 2,335 characters (suitable for Crystal Reports summary field labels)
Byte data (8-bit): 1,555 characters (compatible with ADO.NET DataSet binding)
Numeric data: 3,116 digits (suited for Crystal Reports group header numeric identifiers)
Data Matrix Encoding Data Mode
The Data Matrix symbology uses six encoding modes to optimize data storage. The BarcodeLib library automatically selects the optimal mode when DataMode = DataMatrixDataMode.Auto, which is recommended for dynamic Crystal Reports data:
Base256 (DataMatrixDataMode.Base256): All byte values 0 - 255
Note: Manually setting the encoding mode, such as Base256, is required when handling ASCII non-printable characters in Crystal Reports formula field values.
How to Encode Complex Data in Data Matrix within Crystal Reports
Encode ASCII Non-Printable Characters
Non-printable ASCII characters, such as carriage return, require special handling for Crystal Reports integration:
Replace non-printable characters with a tilde (~) followed by a three-digit ASCII value (e.g., carriage return becomes ~013).
Set ProcessTilde = true to enable tilde processing.
Set DataMode = DataMatrixDataMode.Auto, which is required for extended character support.
Note: When scanning the Data Matrix barcode, the application must process the tilde-encoded characters to restore the original non-printable values, ensuring data accuracy in Crystal Reports.
Render Data Matrix with Unicode Text Encoded
To encode Unicode text (e.g., multilingual data) in Crystal Reports for ASP.NET, WinForms, or WPF:
Instantiate a DataMatrix object.
Set the Data property with the Unicode text; this can be bound to a Crystal Reports parameter field.
Enable EncodeUnicodeText = true to activate Unicode support.
Generate the Data Matrix 2D barcode for rendering in the CrystalReportViewer.
Additional Supported Data Formats
Data Matrix in Crystal Reports supports advanced data formats:
Binary data: Encode raw binary files, such as serialized Crystal Reports data table content.
GS1 business messages: Comply with GS1 Application Identifier standards using the FNC1 property.
Structured Append mode: Split large datasets (e.g., Crystal Reports report footer summaries) across multiple Data Matrix barcodes.
Data Matrix Barcode Dimension Settings in Crystal Reports for .NET
Quick Data Matrix Image Width Configuration
To generate a square Data Matrix image with a specified width suitable for Crystal Reports page headers or footers.
Rectangular Data Matrix Configuration
Data Matrix (ECC200) supports six rectangular symbol sizes, which are ideal for narrow Crystal Reports details sections:
Initialize a DataMatrix object with the target data.
Set FormatMode to the desired rectangular size (e.g., Format_16X48).
Define the Data Matrix barcode width and height to match the symbol's row and column ratio, which is critical for Crystal Reports layout consistency.
How to create barcode with specified size in C#?
Color Configuration
Data Matrix supports custom foreground and background colors. However, scanner compatibility should be validated when colors deviate from standard black and white, particularly for reports printed or exported via Crystal Reports Server.
Image Format Settings
The OutputFileFormat property allows customization of the Data Matrix image format. Raster or vector formats can be selected to suit Crystal Reports exporting and printing requirements.
Advanced Data Matrix Features for Crystal Reports
Format Mode Customization
The FormatMode property specifies the symbol size, with 24 square and 6 rectangular ECC200 formats available to fit the Crystal Reports layout.
Structured Append Mode
To split large datasets across multiple Data Matrix barcodes (e.g., for Crystal Reports subreport data), Structured Append mode can be enabled:
Set StructuredAppend = true.
Set SymbolCount to the total number of Data Matrix barcodes.
Set SymbolIndex to the order index of the current barcode (starting from 0).
Set FileId to a unique random integer; all barcodes storing the same data message must share the same FileId value.
GS1 FNC1 (First Position)
To enable GS1 Application Identifier compliance for supply chain reporting within Crystal Reports, set the FNC1 property to FNC1.FNC1_1ST_POS.
Summary
This guide has demonstrated how to create, print, and customize Data Matrix 2D barcodes in Crystal Reports using the BarcodeLib Barcode Generator for Crystal Reports .NET library.
Generate Data Matrix barcodes in C# and bind them to Crystal Reports for .NET using ReportDocument, CrystalReportViewer, and .rpt file templates. The same approach applies to WinForms, WPF (via WindowsFormsHost), and ASP.NET Web Forms, with VB.NET syntax following the same pattern.
Utilize automatic or manual encoding modes to support ASCII, Unicode, and GS1 data. Non-printable characters are handled through tilde processing, which is essential for binding to Crystal Reports formula fields and parameter fields.
Customize barcode dimensions (square or rectangular), colors, and image formats to align with Crystal Reports layout requirements across headers, footers, and details sections. Advanced features such as Structured Append provide scalability for large datasets.
More Tutorials for Crystal Reports 2D & Linear Barcode Generating