Streaming Data Matrix Image into Your ASP.NET Web Pages
- 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
- Install ASP.NET Barcode Generator Control.
- Add ASP.NET Barcode Generator Control to your Visual Studio ToolBox.
- Copy "datamatrix.aspx" and "datamatrix.aspx.cs" to the folder where your aspx pages are generating barcodes.
- Drag and drop "DataMatrixWebForm" to your ASPX web forms.
- 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
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.
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).
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.
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.
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.
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
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.
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)
- 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.
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.
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.
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.
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.
