How to create, print Data Matrix in Crystal Reports in ASP.NET, WinForms application?

Create Data Matrix Barcodes in Crystal Reports Projects Using .NET Control

Generate Data Matrix barcode images on Crystal Reports using .NET Barcode Library

  • Free trial package and complete optional VB, C# sample codes available
  • Generate dynamic Data Matrix barcode symbology in Crystal Reports
  • Full access to properties of Crystal Report and the underlying report objects
  • Create robust report solution using Visual Studio 2005/2008/2010
  • Compliant with .NET Framework 2.0/3.0/3.5/4.0
  • Build customized Crystal Report using Dynamic data connections
  • Adjust barcode height, width, X-dimension using VB.NET or C# codes
  • Create accurate Data Matrix based on ISO / IEC 16022 (2nd edition 2006-09-15)


Here we will learn how to create, customize, print Data Matrix 2d barcodes in Crystal Reports in ASP.NET and Windows Forms applications.

Create Data Matrix in Crystal Report in ASP.NET Create Data Matrix in Crystal Report in Windows Forms


How to create, print Data Matrix in Crystal Reports in Visual Studio project?

  1. Download Crystal Reports Data Matrix Barcode Generator library
  2. Install Crystal Reports Barcode Generator dll file into Visual Studio .NET project
  3. Start to Create










Introduction of Data Matrix Crystal Reports Barcode Generator

Top
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

Top
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,
  • For ASP.NET project, open file Default.aspx.cs
  • For Windows Forms project, open file Form1.cs
Follow these steps to generate Data Matrix and embed it into a Crystal Report:

  1. Remove or comment out the existing Linear object generation code.
  2. Instantiate a DataMatrix barcode object (core class for Data Matrix 2D barcode generation).
  3. Assign the target data string to the Data property of the barcode object (map this to a Crystal Reports Parameter field for dynamic data).
  4. 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#)

Top

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?

Top

Encode ASCII Non-Printable Characters in Data Matrix

Non-printable ASCII characters (e.g., carriage return) require special handling for Crystal Reports integration:
  1. Replace non-printable chars with '~' + 3-digit ASCII value (e.g., carriage return = "~013").
  2. Set ProcessTilde = true to enable tilde processing.
  3. 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:
  1. Instantiate a DataMatrix object.
  2. Set the Data property with Unicode text (bind to Crystal Reports Parameter field).
  3. Enable EncodeUnicodeText = true to activate Unicode support.
  4. 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#)

Top

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):
  1. Initialize a DataMatrix object with target data.
  2. Set FormatMode to the desired rectangular size (e.g., Format_16X48).
  3. 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#)

Top

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#)

Top

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 SymbolCount with the total Data Matrix files count
  • Set property SymbolIndex with the order of the current Data Matrix. The first symbol index is 0.
  • Set property FileId with 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 FNC1 with value FNC1.FNC1_1ST_POS
barcode.FNC1 = FNC1.FNC1_1ST_POS;




Summary

Top
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.

















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
If you try to encode text which is over the maximum Data Matrix capacity, the Crystal Reports for .NET barcode SDK will create an empty image with error message in your Crystal Reports report viewer or reports in .NET WinForms, ASP.NET application.

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
  • ECC 000-140
  • ECC 200 (Recommended by ISO/IEC 16022)
Data Matrix barcode also has two types of symbol size, in square or in rectangular.

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.




































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.