Introduction of Data Matrix Crystal Reports Barcode Generator
Data Matrix Barcode Control for Crystal Report is designed to generate high quality Data Matrix barcode symbology into Crystal Report. Data Matrix could be maintained on the exported files such as PDF, Word, Excel and rich text formats.
OnBarcode.com provides Data Matrix Barcode Control for Crystal Reports and other barcode control for generating 30+ other linear & 2D bar codes for Crystal Reports 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, MSI Plessey, POSTNET etc.
- 2D Barcodes in Crystal Reports: including QR Code, Data Matrix, PDF-417
How to Generate Data Matrix in .NET Using Crystal Reports Barcode SDK
This page guide provides a structured, step-by-step approach to generating Data Matrix (a 2D matrix barcode symbology) in Crystal Reports for .NET within ASP.NET and WinForms projects. It covers core implementation, data encoding, dimension configuration, color/image settings, and advanced features 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 Data Matrix 2d barcodes in Crystal Reports in the .NET application.
Print Data Matrix in Crystal Report
Here we will start to modify the tutorial project to insert Data Matrix 2d barcodes in the Crystal Reports report designer and print the Data Matrix in the report viewer.
In Visual Studio IDE,
After successfully generating the Data Matrix in Crystal Reports in your C# ASP.NET/WinForms project, we will customize the Data Matrix in the report.
In Visual Studio IDE,
- For ASP.NET project, open file
Default.aspx.cs - For Windows Forms project, open file
Form1.cs
- Remove or comment out the existing
Linearobject generation code. - Instantiate a
DataMatrixbarcode object (core class for Data Matrix 2D barcode generation). - 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 Data Matrix barcode as a byte array and store the Data Matrix as a PNG image file in byte[] object (the standard format for Crystal Reports image controls in .rpt files).
//Linear linear = new Linear(); DataMatrix barcode = new DataMatrix();
After successfully generating the Data Matrix in Crystal Reports in your C# ASP.NET/WinForms project, we will customize the Data Matrix in the report.
- Data Matrix data encoding and data mode selection
- Data Matrix size customization
- Configure Data Matrix colors and image settings
Data Matrix Barcode Data Characters Encoding in Crystal Reports for .NET (C#)
Data Matrix 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).
Data Matrix Maximum Data Length Size
Data Matrix data capacity varies by encoding mode (critical for Crystal Reports Filtering/Grouping of large datasets):
- Alphanumeric data: Up to 2,335 characters (ideal 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
Data Matrix Symbology uses six encoding modes (schemes) to optimize data storage. The OnBarcode library auto-selects the optimal mode when
DataMode = DataMatrixDataMode.Auto (recommended for dynamic Crystal Reports data):
- ASCII
DataMatrixDataMode.ASCII: Double-digit numerics, ASCII 0-127, Extended ASCII 128-255 - C40
DataMatrixDataMode.C40: Upper-case alphanumeric, lower case/special characters - Text
DataMatrixDataMode.Text: Lower-case alphanumeric, upper case/special characters - X12
DataMatrixDataMode.X12: ANSI X12 EDI dataset - EDIFACT
DataMatrixDataMode.Edifact: ASCII 32-94 - Base256
DataMatrixDataMode.Base256: All byte values 0-255
Note: Manually setting the encoding mode (e.g., Base256) is required for ASCII non-printable characters in Crystal Reports Formula field values.
How to encode complex data in Data Matrix in Crystal Reports?
Encode ASCII Non-Printable Characters in Data Matrix
Non-printable ASCII characters (e.g., carriage return) require special handling for Crystal Reports integration:
- Replace non-printable chars with '~' + 3-digit ASCII value (e.g., carriage return = "~013").
- Set
ProcessTilde = trueto enable tilde processing. - Set
DataMode = DataMatrixDataMode.Auto(required for extended character support).
DataMatrix barcode = new DataMatrix(); barcode.Data = "Data~013Matrix"; barcode.ProcessTilde = true; barcode.DataMode = DataMatrixDataMode.Auto;
Note: When scanning the Data Matrix barcode, ensure your application processes the tilde-encoded characters to restore the original non-printable values (critical for Crystal Reports data accuracy).
Render Data Matrix with Unicode text encoded in Crystal Reports
To encode Unicode text (e.g., multilingual data) in Crystal Reports for ASP.NET/WinForms:
- Instantiate a
DataMatrixobject. - Set the
Dataproperty with Unicode text (bind to Crystal Reports Parameter field). - Enable
EncodeUnicodeText = trueto activate Unicode support. - Generate the Data Matrix 2d barcode for rendering in CrystalReportViewer.
DataMatrix barcode = new DataMatrix(); barcode.Data = "Unicode text here"; barcode.EncodeUnicodeText = true;
Additional Supported Data Formats
Data Matrix in Crystal Reports supports advanced data formats:
- Binary data: Encode raw binary files (e.g., serialized Crystal Reports Data Table data).
- GS1 business messages: Comply with GS1 Application Identifier standards (use 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 (C#)
Quick Data Matrix Image Width Configuration
To generate a square Data Matrix image with a specified width (fits Crystal Reports Page Header/Footer):
DataMatrix barcode = new DataMatrix(); barcode.Data = "Data Matrix"; barcode.BarcodeWidth = 300;
Rectangular Data Matrix Configuration
Data Matrix (ECC200) supports 6 rectangular symbol sizes (ideal for narrow Crystal Reports Details section):
- Initialize a
DataMatrixobject with target data. - Set
FormatModeto the desired rectangular size (e.g.,Format_16X48). - Define Data Matrix barcode width/height to match the symbol's row/column ratio (critical for Crystal Reports layout).
DataMatrix barcode = new DataMatrix(); barcode.Data = "Data Matrix"; barcode.FormatMode = DataMatrixFormatMode.Format_16X48; barcode.BarcodeWidth = 900; barcode.BarcodeHeight = 300;
Data Matrix Color and Image Settings for Crystal Reports (C#)
Color Configuration
Data Matrix supports custom foreground/background colors (ensure scanner compatibility for Crystal Reports printing/exporting):
barcode.ForeColor = Color.Red; barcode.BackColor = Color.White;
Note: Non-standard colors may not be readable by all scanners - validate before deploying to Crystal Reports Server for Report distribution.
Image Format Settings
Customize Data Matrix image format through property
OutputFileFormat. Generate Data Matrix in raster/vector formats for Crystal Reports Exporting/Printing:
barcode.OutputFileFormat = FileFormat.PNG;
Advanced Data Matrix Features for Crystal Reports (C#)
Format Mode Customization
Use property
FormatMode to specify symbol size (24 square/6 rectangular ECC200 formats) to fit Crystal Reports layout:
barcode.FormatMode = DataMatrixFormatMode.Format_48X48;
Structured Append Mode
Use Data Matrix in Structured Append mode to split large datasets (e.g., Crystal Reports Subreport data) across multiple Data Matrix barcodes.
- Enable Sturectured Append mode in Data Matrix
- Set property
SymbolCountwith the total Data Matrix files count - Set property
SymbolIndexwith the order of the current Data Matrix. The first symbol index is 0. - Set property
FileIdwith a random unique integer. All data matrix barcodes to store the same data message should have the same FileId value.
DataMatrix barcode = new DataMatrix(); arcode.Data = "Data Matrix"; barcode.StructuredAppend = true; barcode.SymbolCount = 3; barcode.SymbolIndex = 0; barcode.FileId = 999;
GS1 FNC1 (First Position)
Enable GS1 Application Identifier compliance (for supply chain Crystal Reports):
- Set property
FNC1with valueFNC1.FNC1_1ST_POS
barcode.FNC1 = FNC1.FNC1_1ST_POS;
Summary
Now we have learned how to create, print Data Matrix 2d barcodes in Crystal Reports and customize it using OnBarcode Barcode Generator for Crystal Reports C# library.
Core Integration: Generate Data Matrix in C# and bind it to Crystal Reports for .NET using ReportDocument, CrystalReportViewer, and .rpt file templates (compatible with ASP.NET Web Forms/WinForms PictureBox controls).
Data Encoding: Use auto/manual encoding modes to support ASCII/Unicode/GS1 data, and handle non-printable characters with tilde processing (critical for Crystal Reports Formula field and Parameter field binding).
Configuration: Customize dimensions (square/rectangular), colors, and image formats to fit Crystal Reports layout (Header/Footer/Details sections), and use advanced features like Structured Append for large datasets.
Core Integration: Generate Data Matrix in C# and bind it to Crystal Reports for .NET using ReportDocument, CrystalReportViewer, and .rpt file templates (compatible with ASP.NET Web Forms/WinForms PictureBox controls).
Data Encoding: Use auto/manual encoding modes to support ASCII/Unicode/GS1 data, and handle non-printable characters with tilde processing (critical for Crystal Reports Formula field and Parameter field binding).
Configuration: Customize dimensions (square/rectangular), colors, and image formats to fit Crystal Reports layout (Header/Footer/Details sections), and use advanced features like Structured Append for large datasets.
Common Asked Questions
What is data matrix?
Data Matrix barcode is one of the 2d or matrix barcode symbologies that is made of black (bar) and white (space) modules that are usually arranged in a square pattern.
Data Matrix barcodes are capable of storage of both text and binary data, and are smaller and more compact than QR codes.
Using OnBarcode .NET Crystal Reports Barcode Generator SDK, you can easily create, encode, print and insert Data Matrix barcodes into Crystal reports designer and report viewer.
How much data can a Data Matrix barcode hold?
A Data Matrix barcode can hold a maximum of data:
- Alphanumeric data: up to 2,335 characters
- Byte data (8-bit): 1,555 characters
- Numeric data: 3,116 digits
What is the minimum and maximum size of Data Matrix barcode?
In Data Matrix ISO standard, ECC200 Data Matrix minimum dimension size is 10 x 10 modules. And the maximum dimension size of Data Matrix is 144 x 144 modules.
Each modules are in squares.
OnBarcode Crystal Reports for .NET Barcode library supports all formats defined in Data Matrix ISO standard.
What is the ISO standard for Data Matrix barcode?
Data Matrix ISO specification is ISO/IEC 16022, and the latest standard version is ISO/IEC 16022:2024.
Data Matrix barcode is a 2D barcode symbology, which is also supporting ISO 15415 for 2D label-based barcodes.
.NET Crystal Reports Barcode Generator library fully supports ISO compatible Data Matrix generations in Crystal reports in Visual Studio .NET IDE.
What are the different types of Data Matrix?
According to Data Matrix latest ISO standard (ISO/IEC 16022), there are two versions of Data Matrix
OnBarcode Crystal Reports Barcode Library for VS.NET supports Data Matrix ECC200 in square or in rectangle, which uses the Reed-Solomon error correction.
- ECC 000-140
- ECC 200 (Recommended by ISO/IEC 16022)
OnBarcode Crystal Reports Barcode Library for VS.NET supports Data Matrix ECC200 in square or in rectangle, which uses the Reed-Solomon error correction.
Can a phone scan a Data Matrix barcode?
Of course you can.
Data Matrix barcodes printed in the Crystal Reports can be easily scanned using barcode scanners or your smartphone (iPhone or Android phone) equipped with barcode scanning apps.
What is the difference between Data Matrix and QR Code?
Data Matrix and QR Code have lot of same features. They are both 2 dimensional (matrix) barcodes, and enable to encode plain text, Unicode text, binary data.
Both of them are encoding GS1 business data messages. Both of Data Matrix and QR Code support Macro, which allows storing large data into multiple Data Matrixs or QR Codes.
Crystal Reports for .NET Barcode SDK fully supports both Data Matrix and QR Code 2d barcodes generation in Crystal reports in Visual Studio ASP.NET, WinForms projects.