.NET Data Matrix Generator SDK Library
Generate, draw Data Matrix 2D barcode images for Visual C#, VB.NET, ASP.NET projects
Download .NET Barcode Generator Free Evaluation
Purchase .NET Barcode Generator Suite License
"For a new project, I'd try some barcode tools and compare them. I have to say your barcode toolkit is more flexible than other toolkits on the market."
- Norris Wilson, US

Generating & Printing Data Matrix in .NET, C#, ASP.NET, VB.NET using .NET Data Matrix 2D Barcodes Generator

  • Generate Data Matrix 2D Barcodes in C#, VB.NET class & console applications
  • Generate Data Matrix in ASP.NET web applications, webform, website
  • Printing Data Matrix in .NET Windows Forms project
  • Create & Print Data Matrix in Reporting Services, RDLC and Crystal Reports
  • Compatible with ISO / IEC 16022 (2nd edition 2006-09-15) to create readable Data Matrix barcode
  • High quality Data Matrix Bar Code images in GIF, PNG, JPEG & BITMAP formats
  • Completely developed in Visual C#.NET source codes
  • Easy to use Data Matrix barcode generating components used by 1000+ clients






.NET Barcode Data Matrix Generator Introduction
Top
Generating Barcode Data Matrix in .NET is one of the functions in OnBarcode's .NET Barcode Generators, which supports creating & printing Data Matrix and other 30+ linear & 2D bar codes for C#, VB.NET & ASP.NET applications.
OnBarcode develops several .NET Barcode Generation components for different .NET development environments:

.NET Data Matrix Generator - Barcode Data Matrix Introduction

Data Matrix, also known as Data Matrix ECC200, is a two-dimensional matrix barcode consisting of black and white "cells" or modules arranged in either a square or rectangular pattern. The information to be encoded can be text or raw data. Usual data size is from a few bytes up to 2 kilobytes. The length of the encoded data depends on the symbol dimension used. Error correction codes are added to increase symbol strength: even if they are partially damaged, they can still be read. A Data Matrix symbol can store up to 2,335 alphanumeric characters.

.NET Data Matrix Generation - Data Matrix Valid Data Scope

.NET Data Matrix Generator encodes:
  • all 128 characters of ASCII.
  • values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII
How to Generate & Print Data Matrix in Visual Studio C# or VB.NET class?
Top
Generating barcode Data Matrix in C# Class example (C# Data Matrix Generator Complete Demo Source Code):
   DataMatrix datamatrix = new DataMatrix();
datamatrix.Data = "0123456789";
datamatrix.X = 3;

// Generate Data Matrix and encode barcode to gif format
datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;
datamatrix.drawBarcode("C://csharp-datamatrix.gif");

// Print Data Matrix to C# Bitmap object
Bitmap datamatrixBitmap = datamatrix.drawBarcode();
Generating barcode Data Matrix in VB.NET Class example (VB.NET Data Matrix Generator Complete Demo Source Code):
   Dim datamatrix As OnBarcode.Barcode.DataMatrix
datamatrix = New OnBarcode.Barcode.DataMatrix()
datamatrix.Data = "0123456789"
datamatrix.X = 3

' Generate Data Matrix and encode barcode to png format
datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
datamatrix.drawBarcode("C://vbnet-datamatrix.png")

' Print Data Matrix to vb.net Bitmap object
Dim datamatrixBitmap As Bitmap
datamatrixBitmap = datamatrix.drawBarcode()
How to Create & Draw Data Matrix Image in ASP.NET aspx or Html Pages Without ASP.NET Barcode Controller?
Top
  • Under demo package, copy barcode folder and its contents to your IIS, and create a new virtual directory.
  • Restart IIS, navigate to http://YourDomain:Port/barcode/datamatrix.aspx?DATA=0123456789.
  • To create barcode Data Matrix image in html or aspx pages, you can insert a image tag (img) into your page.
    For example, <img src="http://YourDomain:Port/barcode/datamatrix.aspx?DATA=0123456789"/>
How to Create & Encode Barcode Data Matrix to Image File (GIF, JPEG, PNG, BMP)?
Top
Creating barcode Data Matrix in C# Class example:
   DataMatrix datamatrix = new DataMatrix();
datamatrix.Data = "0123456789";

// Create Data Matrix and encode barcode to Jpeg format
datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
datamatrix.drawBarcode("C://csharp-datamatrix.jpg");
Creating barcode Data Matrix in VB.NET Class example:
   Dim datamatrix As OnBarcode.Barcode.DataMatrix
datamatrix = New OnBarcode.Barcode.DataMatrix()
datamatrix.Data = "0123456789"

' Create Data Matrix and encode barcode to Jpeg format
datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg
datamatrix.drawBarcode("C://vbnet-datamatrix.jpg")
How to Generate GS1 Compatible Data Matrix?
Top
  1. You need set property FNC1 value to FNC1.FNC1_1ST_POS (1), to indicate that the generated data matrix is GS1 compatible.
  2. You can use 2 methods to input GS1 AI elements.
    1. Parenthesis: to use parenthesis to indicate an AI code. Eg. (01)12345.
    2. Escape Tilde: to use ~ai* to indicate an AI while * is digit number of the AI (from 2 ~ 7). Eg. ~ai20112345 same as (01)12345.
  • To use escape tilde, you need set processTilde property to true.
  • You can not use parenthesis character in the data message, except, user enables ProcessTilde flag and use ~040 and ~041 to replace '(' and ')'. Parenthesis must in pair, otherwise, the output would be incorrect.
Data Matrix Reader Programming and Macro 05, Macro 06
Top
To encode Data Matrix reader programming, macro 05 and macro 06, you need set ProcesTilde property to true, and add one of the following message to the beginning of the encoding Data Matrix data.
  1. ~rp: Reader Programming (for ASCII mode and Auto mode only)
  2. This should be located at the beginning of the encoding data, e.g. data = "~rpABCD1234".
  3. ~m5: 05 Macro (for ASCII mode and Auto mode only)
  4. This should be located at the beginning of the encoding data, e.g. data = "~m5ABCD1234".
  5. ~m6: 06 Macro (for ASCII mode and Auto mode only)
  6. This should be located at the beginning of the encoding data, e.g. data = "~m6ABCD1234".
In Visual Studio C# & VB.NET, How to Draw Barcode Data Matrix to .NET Graphics, Stream & Bitmap Objects?
Top
To draw & print barcode Data Matrix to C# objects:
   public void drawBarcode(Graphics graphics);

public void drawBarcode(string filename);

public Bitmap drawBarcode();

public void drawBarcode(Stream fileStream);
This should be located at the beginning of the encoding data, e.g. data = "~m6ABCD1234".
   Public Sub drawBarcode(ByRef graphics As Graphics)

Public Sub drawBarcode(ByVal filename As String)

Public Function drawBarcode() As Bitmap

Public Sub drawBarcode(ByRef fileStream As Stream)
Generating & Printing Barcode Data Matrix using .NET Barcode WinForms Controller
Top
  1. Add OnBarcode.Barcode.WinForms.dll to .net project reference.
  2. Add .NET Barcode to .NET Visual Studio Toolbox.
    1. Right click .NET Visual Studio Toolbox, select menu Choose Items...
    2. In "Choose Toolbox Items" form, click button "Browse...", and select dll OnBarcode.Barcode.WinForms.dll.
    3. After selection, you will find four items under "Components" section: LinearWinForm, DataMatrixWinForm, PDF417WinForm, and QRCodeWinForm.
Creating & Drawing Barcode Data Matrix using ASP.NET Barcode Web Form Controller
Top
  1. Add OnBarcode.Barcode.ASPNET.dll to asp.net project reference.
  2. Add .NET Barcode to .NET Visual Studio Toolbox.
    1. Right click .NET Visual Studio Toolbox, select menu Choose Items...
    2. In "Choose Toolbox Items" form, click button "Browse...", and select dll OnBarcode.Barcode.ASPNET.dll.
    3. After selection, you will find four items under "Components" section: LinearWebForm, DataMatrixWebForm, PDF417WebForm, and QRCodeWebForm.
.NET Data Matrix Generator - Barcode Properties
Top
Category Properties Value Comments
Basic Property: Data
URL: DATA
Type: string
Default: "DataMatrix"
Barcode value to encode

Data Matrix Valid Data Char Set:
  • ASCII values 0 - 127 in accordance with the US national version of ISO/IEC 646
    NOTE: This version consists of the G0 set of ISO/IEC 646 and the C0 set of ISO/IEC 6429 with values 28 - 31 modified to FS, GS, RS and US respectively.
  • ASCII values 128 - 255 in accordance with ISO 8859-1. These are referred to as extended ASCII.

 
Data Matrix
Special
Property: ProcessTilde
URL: PROCESS-TILDE
Type: bool
Default: true
Set the ProcessTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is true.
  • 1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); ASCII character '~' is presented by ~126
    Strings from "~256" to "~299" are unused
  • 2-byte character (Unicode): ~6ddddd (character value from 00000 ~ 65535)
    Strings from "~665536" to "~699999" are unused
  • for GS1 AI Code:
    ~ai2: AI with 2 digits
    ~ai3: AI with 3 digits
    ~ai4: AI with 4 digits
    ~ai5: AI with 5 digits
    ~ai6: AI with 6 digits
    ~ai7: AI with 7 digits
  • ECI: ~7dddddd (valid value of dddddd from 000000 to 999999)
  • ~rp: Reader Programming (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~rpABCD1234".
  • ~m5: 05 Macro (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~m5ABCD1234".
  • ~m6: 06 Macro (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~m6ABCD1234".
Property: DataMode
URL: DATA-MODE
Type: DataMatrixDataMode

Default: DataMatrixDataMode.
ASCII (1)
Data Matrix data encoding mode.

Valid values are:
  • DataMatrixDataMode.Auto (0): Barcode library will decide the best data mode for you.
  • DataMatrixDataMode.ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127). This is the default encoding format by Barcode Library.
  • DataMatrixDataMode.C40 (2): it is used to encode data that mainly contains numeric and upper case characters.
  • DataMatrixDataMode.Text (3): it is used to encode data that mainly contains numeric and lower case characters.
  • DataMatrixDataMode.X12 (4):it is used to encode the standard ANSI X12 electronic data interchange characters.
  • DataMatrixDataMode.Edifact (5): it is used to encode 63 ASCII values (values from 32 to 94) plus an Unlatch character (binary 011111).
  • DataMatrixDataMode.Base256 (6): it is used to encode 8 bit values.
Property: FormatMode
URL: FORMAT-MODE
Type: DataMatrixFormatMode

Default: DataMatrixFormatMode.
Format_10X10 (0)
Default is DataMatrixFormatMode.Format_10X10 (0). Specifies the Data Matrix Format to use on that symbology. Valid values see enum DataMatrixFormatMode.Format_*X*;
Property: FNC1
URL: FNC1
Type: FNC1

Default: FNC1.
FNC1_NONE (0)
To encode GS1 compatible Data Matrix barcode, you need set FNC1 value to FNC1.FNC1_1ST_POS (1).
Property: StructuredAppend
URL: STRUCTURED-APPEND
Type: bool
Default: false
Set StructuredAppend property to true, then Structured Append is enabled.
Property: SymbolCount
URL: SYMBOLE-COUNT
Type: int
Default: 0
Set SymbolCount property to the number of total symbols which make the sequence.
Property: SymbolIndex
URL: SYMBOL-INDEX
Type: int
Default: 0
Set SymbolIndex property to the position of current symbol in the secuence (Start with 0).
Property: FileId
URL: FILE-ID
Type: int
Default: 0
Set FileId property to be identified to the same file.
 
Barcode
Size
Related
Property: AutoResize
URL: AUTO-RESIZE
Type: bool
Default: false
Auto resize the generated barcode image
Property: BarAlignment
URL: BAR-ALIGNMENT
Type: int
Default: 1 (center)
Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right.
Property: UOM
URL: UOM
Type: UnitOfMeasure
Default: PIXEL (0)
Unit of meature for all size related settings in the library.

Valid values:
  • UnitOfMeasure.PIXEL (0)
  • UnitOfMeasure.CM (1)
  • UnitOfMeasure.INCH (2)
Property: X
URL: X
Type: float
Default: 3
barcode module width and height, default is 3 pixel
Property: BarcodeWidth
URL: BARCODE-WIDTH
Type: float
Default: 0
Barcode image width.

If BarcodeWidth setting is smaller than the barcode required minimum width, the library will automatically reset to barcode minimum width.
Property: BarcodeHeight
URL: BARCODE-HEIGHT
Type: float
Default: 0
Barcode image height.

If BarcodeHeight setting is smaller than the barcode required minimum height, the library will automatically reset to barcode minimum height.
Property: LeftMargin
URL: LEFT-MARGIN
Type: float
Default: 0
Barcode image left margin size.
Property: RightMargin
URL: RIGHT-MARGIN
Type: float
Default: 0
Barcode image right margin size.
Property: TopMargin
URL: TOP-MARGIN
Type: float
Default: 0
Barcode image top margin size.
Property: BottomMargin
URL: BOTTOM-MARGIN
Type: float
Default: 0
Barcode image bottom margin size.
Property: Resolution
URL: RESOLUTION
Type: int
Default: 72
Barcode image resolution in DPI (Dots per inch).
Property: Rotate
URL: ROTATE
Type: Rotate
Default: Rotate.Rotate0 (0)
Valid values:

  • Rotate.Rotate0 (0)
  • Rotate.Rotate90 (1)
  • Rotate.Rotate180 (2)
  • Rotate.Rotate270 (3)
 
Barcode
Colors
Property: BackColor
URL: BACK-COLOR
Type: Color
Default: white
Barcode image background color
Property: ForeColor
URL: FORE-COLOR
Type: Color
Default: black
Barcode image foreground color
 
In WebStream query string, please use int value for Enums, "true" and "false" for bool.
 
How to create Data Matrix barcodes in C#? Complete example source code
   using System;
using System.Collections.Generic;
using System.Text;
using OnBarcode.Barcode;
using System.Drawing.Imaging;
using System.Drawing;


DataMatrix datamatrix = new DataMatrix();

// Barcode data to encode
datamatrix.Data = "OnBarcode";
// Data Matrix data mode
datamatrix.DataMode = DataMatrixDataMode.ASCII;
// Data Matrix format mode
datamatrix.FormatMode = DataMatrixFormatMode.Format_16X16;

/*
* Barcode Image Related Settings
*/
// Unit of meature for all size related setting in the library.
datamatrix.UOM = UnitOfMeasure.PIXEL;
// Bar module size (X), default is 3 pixel;
datamatrix.X = 3;
// Barcode image left, right, top, bottom margins. Defaults are 0.
datamatrix.LeftMargin = 0;
datamatrix.RightMargin = 0;
datamatrix.TopMargin = 0;
datamatrix.BottomMargin = 0;
// Image resolution in dpi, default is 72 dpi.
datamatrix.Resolution = 72;
// Created barcode orientation.
//4 options are: facing left, facing right, facing bottom, and facing top

datamatrix.Rotate = Rotate.Rotate0;

// Generate data matrix and encode barcode to gif format
datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;
datamatrix.drawBarcode("C:\\datamatrix.gif");

/*
You can also call other drawing methods to generate barcodes

public void drawBarcode(Graphics graphics);

public void drawBarcode(string filename);

public Bitmap drawBarcode();

public void drawBarcode(Stream stream);

*/
All .NET Barcode Generator Supporting Bar Code Types
Top

Barcode Generator DLL for .NET - Bar Code Types Generation

OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.