C# Data Matrix Barcode generator library: generate, create, render data matrix 2d barcode from string data with free open source c# example. no font
- Completely compatible with .NET Framework 2.0 and later versions
- Easy to generate Data Matrix ECC 200 barcodes in Visual C#.NET programming
- Dynamically generating Data Matrix in ASP.NET, WinForms, Crystal Reports and RDLC Reports
- Draw Data Matrix barcode images in stream & graphics object and save in multiple image formats
- Offer various barcode settings for Data Matrix including module width, format mode, margins, etc
- Puchase royalty-free and permanent license of .NET Data Matrix Barcode Generator Library
C# Data Matrix Barcode Control Description
KA.Barcode for .NET Suite is a mature and reliable barcoding encoder control SDK for generating two-dimensional Data Matrix images in .NET development environment.
Developers can easily create and display Data Matrix in ASP.NET web pages, Windows Forms & Crystal Reports with C# programming. Flexible barcode settings are also available for users to customize generated images.
What Is A Data Matrix Barcode
Data Matrix, also named as ECC200, 2D DataMatrix barcode, is a two-dimensional matrix barcode commonly used to mark small items.
Being space-efficient, Data Matrix is recommended by American EIA for labeling small electronic components.
Data Matrix Valid Data Sets
- All 128 characters of ASCII.
- Extended ASCII (ISO 8859-1 values 128-255)
Create GS1 Compatible Data Matrix
- Set FNC1 to KeepAutomation.Barcode.FNC1.First
- In barcode data setting CodeToEncode, around AI code with "()", and followed by AI data, such as "(02)225(03)33344". Here "02", "03" are the AI code, "225", "33344" is the AI data,
Encode Non-printable Chars in Data Matrix
- Set TildeEnabled to true
- Use '~ddd' for non-printable chars. For example, ASCII char [GS] is non-printable, and its decimal value is 29. In barcode data, you need use ~029 for char [GS].
Encode byte[] in Data Matrix
The following C# source codes demo how to encode byte[] object in Data Matrix
// Byte array to encode
byte[] dataBytes = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45 };
// Convert byte array to the input (property CodeToEncode)
String inputMsg = "";
foreach (byte b in dataBytes)
inputMsg += "~" + b.ToString().PadLeft(3, '0');
// Create barcode
BarCode barcode = new BarCode();
barcode.Symbology = Symbology.DataMatrix;
barcode.DataMatrixDataMode = DataMatrixDataMode.Base256;
// enable '~' in the input message
barcode.TildeEnabled = true;
barcode.CodeToEncode = inputMsg;
// set module size to 5 pixels
barcode.BarcodeUnit = BarcodeUnit.Pixel;
barcode.X = 5;
barcode.Y = 5;
barcode.generateBarcodeToBitmap().Save(@"C:\DataMatrix_Bytes.png");
Encode Japanese (non-English) text in Data Matrix
The following C# source codes demo how to encode non English text (such as Japanese text) in Data Matrix
// Message in Japanese
String unicodeMsg = @"おはようございます";
// Convert Unicode string to data bytes
byte[] dataBytes = Encoding.Unicode.GetBytes(unicodeMsg);
// Convert byte array to the input (property CodeToEncode)
String inputMsg = "";
foreach (byte b in dataBytes)
inputMsg += "~" + b.ToString().PadLeft(3, '0');
// Create barcode
BarCode barcode = new BarCode();
barcode.Symbology = Symbology.DataMatrix;
barcode.DataMatrixDataMode = DataMatrixDataMode.Base256;
// enable '~' in the input message
barcode.TildeEnabled = true;
barcode.CodeToEncode = inputMsg;
// set module size to 5 pixels
barcode.BarcodeUnit = BarcodeUnit.Pixel;
barcode.X = 5;
barcode.Y = 5;
barcode.generateBarcodeToBitmap().Save(@"C:\DataMatrix_Japanese.png");
Generate Barcode Image in Specified Width and Height
- Set property AutoSizeAdjust to true
- Set property DPI to be the same or higher as your printer's resolution
- Set property BarcodeUnit to inch or cm
- Set property BarCodeWidth and BarCodeHeight to your required image width and height
Data Matrix Property Settings
Class Attribute
|
HTTP Attribute
|
Default Value
|
Note
|
Basic
|
Symbology
|
symbology
|
Code128Auto
|
Barcode symoblogy type
|
CodeToEncode
|
code-to-encode
|
"128"
|
Barcode value to encode.
|
ChecksumEnabled
|
checksum-enabled
|
false
|
It is not applied for Data Matrix
|
ImageFormat
|
image-format
|
ImageFormat.Png
|
Barcode encoded image format.
|
Barcode Size
|
AutoSizeAdjust
|
auto-size-adjust
|
false
|
If true, barcode X, Y module will be auto-adjusted.
|
BarcodeUnit
|
barcode-unit
|
BarcodeUnit.Pixel
|
Unit of measure for all size related settings. 0: pixel; 1: inch; 2: cm.
|
X
|
x
|
1
|
Barcode module width (narrow bar).
|
Y
|
y
|
50
|
Linear barcode bar height / 2D barcode module height.
|
LeftMargin
|
left-margin
|
0
|
Barcode image left margin.
|
RightMargin
|
right-margin
|
0
|
Barcode image right margin.
|
TopMargin
|
top-margin
|
0
|
Barcode image top margin.
|
BottomMargin
|
bottom-margin
|
0
|
Barcode image bottom margin.
|
DPI
|
dpi
|
72
|
Barcode image resolution in dpi.
|
Orientation
|
orientation
|
Orientation.Degree0
|
Barcode rotation angle.
|
BarCodeWidth
|
barcode-width
|
0
|
Whole barcode width.
|
BarCodeHeight
|
barcode-height
|
0
|
Whole barcode height.
|
2D / Matrix Group Barcode Properties
|
GroupEnabled
|
group-enabled
|
false
|
Set to enable Data Matrix, PDF417, or QR Code group function.
|
GroupItemCount
|
group-item-count
|
0
|
Data Matrix, PDF417, or QR Code group count.
|
GroupItemId
|
group-item-id
|
0
|
Data Matrix, PDF417, or QR Code group item id.
|
GroupId
|
group-item-id
|
0
|
Data Matrix, PDF417, or QR Code group item.
|
Data Matrix Specific Settings
|
DataMatrixDataMode
|
data-matrix-data-mode
|
DataMatrixDataMode.Auto
|
Set Data Matrix data encoding mode.
- DataMatrixDataMode.Auto: KeepAutomation will select proper data format according to your encoding value.
- DataMatrixDataMode.ASCII: All ASCII characters, including 0-9, A-Z, a-z and special characters like $ , % + / : * etc.
- DataMatrixDataMode.C40: 0-9, A-Z
- DataMatrixDataMode.Text: 0-9, a-z
- DataMatrixDataMode.X12: 0-9, A-Z, and some punctuation marks.
- DataMatrixDataMode.Edifact: 0-9, A-Z, many punctuation marks
- DataMatrixDataMode.Base256: to encode images, double-byte characters, binary data and 8 bit values.
|
DataMatrixFormatMode
|
data-matrix-format-mode
|
DataMatrixFormatMode.FM_12X12
|
Set Data Matrix format mode, including 24 square and 6 rectangle formats.
|
FNC1
|
fnc1
|
FNC1.None
|
To encode GS1 compatible Data Matrix, you need set value to "FNC1.First"
|
TildeEnabled
|
tilde-enabled
|
false
|
Set TildeEnabled to true, specifying special characters in barcode data.
Support escape '~' for data message
-
1-byte character: ~ddd (character value from 0 ~ 255)
ASCII (with EXT): from ~000 to ~255
For example, ASCII char [GS] is non-printable, and its decimal value is 29. In barcode data, you need use ~029 for char [GS].
- 2-byte character: ~6ddddd (character value from 0 ~ 65535)
- Unicode: from ~600000 to ~665535
- ECI: from ~7000000 to ~7999999
- SJIS: from ~9ddddd (Shift JIS 0x8140 ~ 0x9FFC and 0xE040 ~ 0xEBBF)
|
Data Matrix Barcode Creation in ASP.NET Using C#
This KeepAutomation barcode encoder dll for .NET also supports Data Matrix barcode generation in ASP.NET web applications.
Users can easily create Data Matrix barcodes in Websites, Microsoft IIS as well as Visual C# Class Library & Console applications.
Here are more details for you:
How to print barcode in Visual C# with ASP.NET web control.
Data Matrix Barcode Generation in .NET WinForms Using C#
With KeepAutomation barcode generator for .NET Suite, developers can easily create Data Matrix barcodes in .NET Windows Forms with simple control drag-n-drop or C# class library.
For more details or C# sample code, please view
How to create barcode in .NET WinForms with Visual C#.
Data Matrix Barcode Making in Crystal Reports Using C#
KA.Barcode for .NET Suite enables developers to add batch Data Matrix barcodes to Crytal Reports without using any third party tool, like barcode fonts or plugins.
Multiple linear and 2D barcode types are supported with barcode settings available.
Click link here for more details:
How to create barcode in Crystal Reports with Visual C#.
Data Matrix Barcode Adding in RDLC Reports Using C#
KA.Barcode for .NET Suite supports Microsoft Report Definition Language scenarios such as Visual Studio 2005 / 2008 / 2010 ReportViewer Local Reports (RDLC).
With this barcode library SDK, users can print multiple Data Matrix barcodes in no time without using fonts or other third party tool.
View more details here:
How to create barcode in RDLC Reports with C# code.
Data Matrix Barcode Generation in .NET Applications with C#
Here is the easiest way to encode barcodes with this barcode maker using Visual C# Class Library.
What given below is detailed C# sample code to create Data Matrix barcodes in C# class,
with all
barcode properties available for adjustment.
Copy the code to your project now and debug to view generated barcodes!
C# Sample code
BarCode datamatrix = new BarCode();
datamatrix.Symbology = KeepAutomation.Barcode.Symbology.DataMatrix;
//Data Matrix encoding valid input: All ASCII characters, including 0-9, A-Z, a-z, special characters
datamatrix.CodeToEncode = "DataMatrix";
//KeepAutomation provides the following Data Matrix Barcode Data Formats:
//ASCII: All ASCII characters, including 0-9, A-Z, a-z and special characters like $ , % + / : * etc.
//Auto: KeepAutomation will select proper data format according to your encoding value.
//Base256: to encode images, double-byte characters, binary data and 8 bit values.
//C40: 0-9, A-Z
//Edifact: 0-9, A-Z, many punctuation marks
//Text: 0-9, a-z
//X12: 0-9, A-Z, and some punctuation marks.
datamatrix.DataMatrixDataMode = DataMatrixDataMode.Auto;
datamatrix.DataMatrixFormatMode = DataMatrixFormatMode.FM_12X12;
//Set Data Matrix image size
//Data Matrix Unit of measure, support pixel, cm and inch.
datamatrix.BarcodeUnit = BarcodeUnit.Pixel;
// Data Matrix image resolution in dpi
datamatrix.DPI = 72;
// Data Matrix bar module width (X dimention)
datamatrix.X = 3;
//Bar module height (Y dimention), Y=X
datamatrix.Y = 3;
//Data Matrix image left margin size(quiet zone), the minimum value is X.
datamatrix.LeftMargin = 9;
//Image right margin size, the minimum value is X.
datamatrix.RightMargin = 9;
datamatrix.TopMargin = 9;
datamatrix.BottomMargin = 9;
//Barcode image orientation, 0, 90, 180 and 270 degrees supported.
datamatrix.Orientation = KeepAutomation.Barcode.Orientation.Degree0;
//Generate Data Matrix barcodes in PNG image format
datamatrix.generateBarcodeToImageFile("C://barcode-datamatrix-csharp.png");
/* Create Data Matrix barcodes in Stream object
datamatrix.generateBarcodeToStream(".NET System.IO.Stream Object");
Draw & Print Data Matrix barcodes to Graphics object
datamatrix.generateBarcodeToGraphics(".NET System.Drawing.Graphics Object");
Generate Data Matrix barcodes & write to byte[]
byte[] barcodeInBytes = datamatrix.generateBarcodeToByteArray();
Generate Data Matrix barcodes & encode to System.Drawing.Bitmap object
Bitmap barcodeInBitmap = datamatrix.generateBarcodeToBitmap();
*/