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.
How to Print Data Matrix in Crystal Reports?
We have prepared detailed step-by-step instructions how to create, print barcodes in Crystal Reports report in ASP.NET and Windows Forms application.
The above ASP.NET and WinForms demo application will create and print Code 128 barcodes in the report.
To generate Data Matrix barcodes in the report, you need do the following code modification.
For ASP.NET web application, open file Default.aspx.cs in Visual Studio, go to method Page_Load
For WinForms application, open file Form1.cs in Visual Studio, go to method Form1_Load
Create new barcode object from class DataMatrixCrystal.
protectedvoidPage_Load(objectsender, EventArgse)
{
//LinearCrystal barcode = new LinearCrystal();DataMatrixCrystalbarcode=newDataMatrixCrystal();
Set barcode image size in Crystal Reports report designer.
Open report file CrystalReport1.rpt in Visual Studio. Click the Barcode item, change the properties:
Property XScaling value to the same value in barcode property ImageWidth
Property YScaling value to the same value in barcode property ImageHeight
Here is a sample report with Data Matrix barcodes printed in web browser.
How to Encode Complex Text String in Data Matrix within Crystal Reports
Encode ASCII Non-Printable Characters
Non-printable ASCII characters (control chars), 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 to true to enable tilde processing.
Set barcode item image size in report designer
Click the barcode item in the report designer, set the properties
Set XScaling to 2
Set YScaling to 2
Note: In Crystal Reports the default unit of measure is inch. During barcode generation, we recommend you to set property
UOM (barcod image unit of measure) to value UnitOfMeasure.INCH also.
Rectangular Data Matrix Size Configuration
Data Matrix (ECC200) supports six rectangular symbol sizes, which are ideal for narrow Crystal Reports details sections:
Initialize a DataMatrixCrystal object with the target data.
Set Format 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.
Click the barcode item in the report designer, set the properties
Set XScaling to 3
Set YScaling to 1
How to customize Data Matrix with colors and image settings?
Data Matrix Module 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.
Using Crystal Reports Barcode library, you can create and print high resolution (dpi) Data Matrix image in report and Data Matrix barcode image with transparent background in report
Set property Resolution with a high value (such as 900) for high quality barcode report printing.
Set property BackgroundColor with value Color.Transparent to draw Data Matrix with transparent background in the report.
The Data Matrix Format property specifies the symbol size, with 24 square and 6 rectangular ECC200 formats available to fit the Crystal Reports layout.
barcode.Format=DataMatrixFormat.Format_36X36;
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 EnableStructuredAppend to true to print Data Matrix in Structured Append mode.
Set StructuredAppendCount to the total number of Data Matrix barcodes.
Set StructuredAppendIndex to the order index of the current Data Matrix barcode (starting from 0).
Set StructuredAppendFileID to a unique random integer. All Data Matrix barcodes storing the same data message must share the same
StructuredAppendFileID value.
More about Data Matrix Barcode Data Character Encoding
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 Encoding is DataMatrixEncoding.AUTO, which is recommended for dynamic Crystal Reports data:
Base256 (DataMatrixEncoding.Base256): All byte values 0 - 255
barcode.Encoding=DataMatrixEncoding.AUTO;
Note: Manually setting the encoding mode, such as Base256, is required when handling binary data in Crystal Reports formula field values.
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