ASP.NET Data Matrix Generator Library SDK

Integration & Developer Guide to create Data Matrix in ASP.NET class, ASP.NET web Projects

Generate barcode Data Matrix images in Visual ASP.NET web application with complete sample .NET source code

  • Generate, create Data Matrix in Visual ASP.NET applications
  • Easy to install & integrate 2d barcode Data Matrix generation SDK into ASP.NET developments
  • Fully support GS1 Data Matrix for the GS1 system data message
  • Generate industry standard linear, 2d barcode types including QR Code ASP.NET, EAN ASP.NET, UPC ASP.NET, Code 128 ASP.NET
  • Generate Data Matrix images in ASP.NET class
  • Create barcode Data Matrix in ASP.NET webform application
  • Draw & print Data Matrix in SQL Server Reporting Services (SSRS) & Crystal Reports for ASP.NET projects
  • Easy to encode Data Matrix images to jpeg, gif, png, tiff, bitmap files in ASP.NET program
Here we will learn how to generate Data Matrix in ASP.NET projects using C# and a C# Barcode Library. It covers the entire process from basic implementation to advanced customization, providing step-by-step instructions, code samples in your ASP.NET projects (including ASP.NET Core, MVC, Razor Pages, and Web API).
  • Basic steps to generate Data Matrix in ASP.NET projects, including saving it as a PNG file, storing it in a Stream object, and converting it to a byte array.
  • Data Matrix encoding rules, including valid character sets, maximum data length, and encoding data modes supported in ASP.NET projects.
  • Advanced data encoding methods in ASP.NET, such as encoding non-printable characters, Unicode text, binary data, and GS1 data elements into Data Matrix.
  • Customization options for Data Matrix dimensions, including square/rectangular sizes, module width, quiet zones, and unit of measure.
  • Color and image settings for Data Matrix in ASP.NET, including barcode/background colors, image formats (raster and vector), and resolution.
  • Advanced Data Matrix options in ASP.NET projects, such as Format Mode, Structured Append mode, and FNC1 mode for GS1 compliance.

ASP.NET Data Matrix Generator DLL Introduction

Top
ASP.NET Data Matrix Generator is one of the barcode generation functions in OnBarcode's Barcode for ASP.NET Generation Controls, which generates & prints Data Matrix and 20+ other linear & 2D bar codes in ASP.NET web applications.
This article is providing several methods to use ASP.NET Barcode Generation Control to generate Data Matrix barcodes in ASP.NET web pages, ASP.NET web forms, and ASP.NET classes.

Data Matrix Generators

OnBarcode provides several Data Matrix Generator components and software, such as .NET Data Matrix, Java Data Matrix, C# Data Matrix, VB.NET Data Matrix, iPhone Data Matrix, iPad Data Matrix, Android Data Matrix, Data Matrix Generator.


Streaming Data Matrix Image into Your ASP.NET Web Pages

Top
  • Under downloaded trial package, copy barcode folder and its contents to your IIS, and create a new virtual directory, named "barcode".
  • Restart IIS, navigate to http://YourDomain:Port/barcode/datamatrix.aspx?DATA=0123456789.
  • To embed Code 128 image in html or aspx pages, you can insert a image tag (img) into your web pages.
    For example, <img src="http://YourDomain:Port/barcode/datamatrix.aspx?DATA=0123456789" />

Generate Data Matrix into Your ASP.NET Web Forms

Top
  1. Install ASP.NET Barcode Generator Control.
  2. Add ASP.NET Barcode Generator Control to your Visual Studio ToolBox.
  3. Copy "datamatrix.aspx" and "datamatrix.aspx.cs" to the folder where your aspx pages are generating barcodes.
  4. Drag and drop "DataMatrixWebForm" to your ASPX web forms.
  5. Run the website to view the barcodes generated. To customize Data Matrix settings, view Data Matrix barcode settings.

Generate Data Matrix Barcodes in ASP.NET Class

Top
If you need generate Data Matrix barcodes in your ASP.NET class using C# or VB.NET, we provides complete barcode generation source code for Data Matrix in C# and Data Matrix in VB.NET.


Data Matrix Barcode Data Encoding in ASP.NET Projects

To generate Data Matrix effectively in ASP.NET projects, you need to understand its encoding rules, including valid character sets, maximum data length, and encoding data modes. These rules ensure your Data Matrix is encoded correctly and meets your project's requirements.


Data Matrix Valid Encoding Character Set

Data Matrix supports a wide range of character sets, which can be used in ASP.NET projects to encode different types of data. The supported character sets are:
  • Full ASCII: All 128 ASCII characters (values 0 - 127), suitable for standard text and symbols in ASP.NET web applications.
  • Extended ASCII: ISO 8859-1 characters (values 128-255), including special characters and accented letters.
  • Other character sets (e.g., Arabic, Cyrillic, Greek, Hebrew): Supported when using the Extended Channel Interpretation (ECI) protocol, which is useful for international ASP.NET projects.
Note: For non-ASCII character sets, ensure you use the correct encoding mode to avoid data corruption.


Data Matrix Maximum Data Length

The maximum data length of a Data Matrix depends on the encoding data mode. This is important in ASP.NET projects when encoding large amounts of data (e.g., in Web API requests or Session State). The maximum lengths are:
  • Alphanumeric data: Up to 2,335 characters (efficient for encoding IDs, URLs, or short text in ASP.NET).
  • Byte data (8-bit): 1,555 characters (used for binary data, non-ASCII text, or extended ASCII characters).
  • Numeric data: 3,116 digits (ideal for encoding numbers like product IDs or phone numbers in ASP.NET e-commerce projects).
Note: If your data exceeds the maximum length for a single Data Matrix, use Structured Append mode to split the data into multiple Data Matrix barcodes.


Data Matrix Encoding Data Mode

Data Matrix uses six encoding modes to encode data efficiently. The ASP.NET Barcode Library automatically selects the best mode for your data by default, but you can manually specify it in your ASP.NET project for specific use cases.
  • DataMatrixDataMode.ASCII: For double-digit numerics and ASCII values 0-127 (including extended ASCII 128-255). Suitable for standard text in ASP.NET MVC or Razor Pages.
  • DataMatrixDataMode.C40: For upper-case alphanumeric characters, lower-case characters, and special characters. Useful for encoding mixed-case text in ASP.NET forms.
  • DataMatrixDataMode.Text: For lower-case alphanumeric characters, upper-case characters, and special characters. Similar to C40 but optimized for lower-case text.
  • DataMatrixDataMode.X12: For ANSI X12 EDI (Electronic Data Interchange) data sets, commonly used in ASP.NET projects for business-to-business (B2B) data exchange.
  • DataMatrixDataMode.Edifact: For ASCII values 32-94, used for EDIFACT (Electronic Data Interchange for Administration, Commerce, and Transport) data in ASP.NET Web API.
  • DataMatrixDataMode.Base256: For all byte values 0-255, suitable for binary data, non-printable characters, or Unicode text in ASP.NET projects.
Note: If you do not specify a data mode, the library will use DataMatrixDataMode.Auto to automatically select the most efficient mode for your data. This is recommended for most ASP.NET use cases.


Advanced Data Encoding in Data Matrix (ASP.NET Projects)

ASP.NET projects often require encoding complex data types into Data Matrix, such as non-printable characters, Unicode text, binary data, and GS1 data elements.


Encode Non-Printable Characters in Data Matrix

Non-printable ASCII characters (e.g., Carriage Return [CR], Line Feed [LF]) cannot be directly input in C# code but can be encoded in Data Matrix for ASP.NET projects. To do this, you need to use the ProcessTilde property and convert the character to its three-digit ASCII value.
  • Create a new DataMatrix object in your ASP.NET Controller or Razor Page.
  • Set the Data property to the text containing the non-printable character, represented as "~" plus its three-digit ASCII value (e.g., "Data~013Matrix" for [CR] between "Data" and "Matrix").
  • Set ProcessTilde to true to enable the library to recognize the "~" as a placeholder for non-printable characters.
  • Set DataMode to DataMatrixDataMode.Base256 (required for encoding non-printable characters).
  • Call drawBarcode() to save the Data Matrix to a specified path in your ASP.NET project.
Note: Always use three digits for the ASCII value (e.g., use ~005 for ASCII 5, not ~5). Failure to do so will result in incorrect encoding.


Encode Unicode Text in Data Matrix

Unicode text (e.g., Chinese, Arabic, Russian) can be easily encoded in Data Matrix for ASP.NET projects using the C# Barcode Library. The library provides a dedicated property (EncodeUnicodeText) to simplify this process.
  • Create a new DataMatrix object in your ASP.NET project.
  • Set the Data property to the Unicode text you want to encode.
  • Set EncodeUnicodeText to true (this tells the library to process the Data property as Unicode text).
  • Call drawBarcode() to save the Data Matrix to a file or Stream object.


Data Matrix Barcode Dimension Size in ASP.NET Projects

You can customize the dimension size of Data Matrix in your ASP.NET projects, including square and rectangular sizes, module width, quiet zones, and unit of measure. This ensures the Data Matrix fits your UI design or printing requirements.


Quick Data Matrix Size Customization (Square)

To generate a square Data Matrix with a specified width (height will match the width) in ASP.NET, follow these steps:
  • Create a new DataMatrix object in your ASP.NET project.
  • Set the Data property to the desired data.
  • Set the BarcodeWidth property to the desired width (the height will automatically match the width for square Data Matrix).
  • Call drawBarcode() to save the Data Matrix to a specified path.
Note: Do not set the width to a value smaller than 100 pixels, as this may make the Data Matrix unreadable by scanners.


Generate Rectangular Data Matrix

Data Matrix (ECC200) supports 6 rectangular symbols with specific row and column combinations. In ASP.NET projects, you can create rectangular Data Matrix by setting the FormatMode property and specifying the width and height (matching the row/column ratio).

Supported Rectangular Formats
  • 8 rows x 18 columns
  • 8 rows x 32 columns
  • 12 rows x 26 columns
  • 12 rows x 36 columns
  • 16 rows x 36 columns
  • 16 rows x 48 columns
  • Create a new DataMatrix object in your ASP.NET project.
  • Set the Data property to the desired data.
  • Set FormatMode to the desired rectangular format (e.g., DataMatrixFormatMode.Format_16X48 for 16 rows x 48 columns).
  • Set BarcodeWidth and BarcodeHeight to values that match the row/column ratio of the selected format.
  • Call drawBarcode() to save the rectangular Data Matrix.
Note: Ensure the width and height ratio matches the row/column ratio of the selected format. For example, 16 rows x 48 columns requires a 3:1 width-to-height ratio (48/16 = 3).


Advanced Dimension Settings

The width of a Data Matrix (including quiet zones) can be calculated using the formula: W = Row * X + 2Q, where:
  • W: Barcode width
  • Row: Modules per row (symbol size)
  • X: Width of each module (in pixels, cm, or inches)
  • Q: Width of the quiet zone (on each side)
In ASP.NET projects, you can customize these settings using the following properties:
  • UOM: Unit of measure (PIXEL, CM, or INCH) for dimension settings.
  • X: Width of each module (minimum width is defined by your application's requirements).
  • FormatMode: Symbol size format mode (square or rectangular).
  • LeftMargin, RightMargin, TopMargin, BottomMargin: Quiet zone width (minimum is equal to the module width X).
  • AutoResize: Disable to manually set dimensions (set to false for custom sizes).
  • Resolution: Image resolution (in DPI) for high-quality printing.
Note: Each FormatMode has a maximum data capacity. If your data exceeds this capacity, the library will automatically select a larger format mode.


Advanced Data Matrix Features in ASP.NET Projects

ASP.NET projects may require advanced Data Matrix options to meet specific business needs, such as custom symbol sizes, splitting large data into multiple barcodes, or GS1 compliance. This section covers these advanced options.


Data Matrix Format Mode

Data Matrix ISO standard specifies 24 square symbols and 6 rectangular symbols for ECC 200. Each symbol size has a specific number of rows/columns and data capacity. In ASP.NET projects, you can specify the symbol size using the FormatMode property.

Note: For details on the data capacity of each FormatMode, refer to: Data Matrix ECC 200 symbol attributes.


Data Matrix Structured Append Mode

Structured Append mode allows you to split a large data message into up to multiple Data Matrix barcodes. This is useful in ASP.NET projects when encoding data that exceeds the maximum length of a single Data Matrix.
  • StructuredAppend: Set to true to enable Structured Append mode.
  • SymbolCount: Total number of Data Matrix barcodes needed to store the full data message.
  • SymbolIndex: Position of the current Data Matrix (starts from 0).
  • FileId: A unique integer (same for all Data Matrix barcodes in the sequence) to identify the group.
Note: All Data Matrix barcodes in the sequence must have the same FileId and SymbolCount values. Scanners will combine the data from all barcodes in the sequence to retrieve the full message.


Data Matrix FNC1 in First Position

When FNC1 (Function Character 1) is in the first position of a Data Matrix, it signals that the data conforms to the GS1 Application Identifier (AI) standard. This is useful in ASP.NET projects for encoding product information, expiration dates, and other GS1 data.

Note: Ensure the data is formatted correctly with GS1 AI codes (enclosed in parentheses) to comply with GS1 standards.


Summary

This guide provides a comprehensive details to generating and customizing Data Matrix in ASP.NET projects using C# and a ASP.NET Barcode Library. It covers all key aspects from basic generation to advanced customization.







































Start with free trial package:








































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