Skip to main content

DataMatrixBarcode

Version: 1.0

DataMatrixBarcode

DataMatrixBarcode​

Represents a DataMatrix barcode.

public class DataMatrixBarcode : Barcode
Public Class DataMatrixBarcode
Inherits Barcode

Inheritance: Object → Barcode → DataMatrixBarcode

Licensing​

This class is a DynamicBarcode Creator feature. The following license is required for non-evaluation usage:

  • DynamicBarcode Creator for .NET

Examples​

The following example will Draw a DataMatrix barcode image.

Imports System
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

'Create a barcode object.
Dim barcode As DataMatrixBarcode = New DataMatrixBarcode("Hello World")

'Draw barcode image.
barcode.Draw("C:\barcode.png", 300, ImageFormat.Png)

End Sub
End Module
using System;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
DataMatrixBarcode barcode = new DataMatrixBarcode("Hello World");

// Draw barcode image.
barcode.Draw(@"C:\barcode.png", 300, ImageFormat.Png);

}
}

Remarks​

This class can be used to draw a DataMatrix barcode image.

Constructors​

DataMatrixBarcode(Byte[])​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(Byte[] data)
Public Sub New (data As Byte())

Parameters​

The data of the barcode.

DataMatrixBarcode(Byte[], DataMatrixEncodingType)​

Initializes new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(Byte[] data, DataMatrixEncodingType encodingType)
Public Sub New (data As Byte(), encodingType As DataMatrixEncodingType)

Parameters​

The data of the barcode.

Encoding type of the barcode. DataMatrixEncodingType

DataMatrixBarcode(Byte[], DataMatrixEncodingType, DataMatrixSymbolSize)​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(Byte[] data, DataMatrixEncodingType encodingType, DataMatrixSymbolSize symbolSize)
Public Sub New (data As Byte(), encodingType As DataMatrixEncodingType, symbolSize As DataMatrixSymbolSize)

Parameters​

The data of the barcode.

Encoding type of the barcode. DataMatrixEncodingType

The sybol size of the barcode.

DataMatrixBarcode(Byte[], DataMatrixEncodingType, DataMatrixSymbolSize, DataMatrixFunctionCharacter)​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(Byte[] data, DataMatrixEncodingType encodingType, DataMatrixSymbolSize symbolSize, DataMatrixFunctionCharacter functionCharacter)
Public Sub New (data As Byte(), encodingType As DataMatrixEncodingType, symbolSize As DataMatrixSymbolSize, functionCharacter As DataMatrixFunctionCharacter)

Parameters​

The data of the barcode.

The encoding type of the barcode. DataMatrixEncodingType

The symbol size of the barcode. DataMatrixSymbolSize

The function character of the barcode.

DataMatrixBarcode(String)​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(string text)
Public Sub New (text As String)

Parameters​

The text of the barcode.

DataMatrixBarcode(String, DataMatrixEncodingType)​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(string text, DataMatrixEncodingType encodingType)
Public Sub New (text As String, encodingType As DataMatrixEncodingType)

Parameters​

The text of the barcode.

Encoding type of the barcode. DataMatrixEncodingType

DataMatrixBarcode(String, DataMatrixEncodingType, DataMatrixSymbolSize)​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(string text, DataMatrixEncodingType encodingType, DataMatrixSymbolSize symbolSize)
Public Sub New (text As String, encodingType As DataMatrixEncodingType, symbolSize As DataMatrixSymbolSize)

Parameters​

The text of the barcode.

Encoding type of the barcode. DataMatrixEncodingType

The symbol size of the barcode.

DataMatrixBarcode(String, DataMatrixEncodingType, DataMatrixSymbolSize, DataMatrixFunctionCharacter)​

Initializes a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode(string text, DataMatrixEncodingType encodingType, DataMatrixSymbolSize symbolSize, DataMatrixFunctionCharacter functionCharacter)
Public Sub New (text As String, encodingType As DataMatrixEncodingType, symbolSize As DataMatrixSymbolSize, functionCharacter As DataMatrixFunctionCharacter)

Parameters​

The text of the barcode.

Encoding type of the barcode. DataMatrixEncodingType

The symbol size of barcode.

The function character of the barcode. DataMatrixFunctionCharacter

Properties​

BackColor​

Gets or sets the BackColor of the barcode. (Inherited from Barcode)

public Color BackColor { get; set; }
Public Property BackColor As Color

Property Value​

Color

BarcodeMargin​

Gets or Sets the Margin of the barcode. (Inherited from Barcode)

public Margin BarcodeMargin { get; set; }
Public Property BarcodeMargin As Margin

Property Value​

Margin

BarColor​

Gets or sets the BarColor of the barcode. (Inherited from Barcode)

public Color BarColor { get; set; }
Public Property BarColor As Color

Property Value​

Color

ProcessTilde​

Gets or sets wheter to process tilde character.

public bool ProcessTilde { get; set; }
Public Property ProcessTilde As Boolean

Property Value​

Boolean

Unit​

Gets or sets the Unit of the barcode. (Inherited from Barcode)

public UnitOfMeasurement Unit { get; set; }
Public Property Unit As UnitOfMeasurement

Property Value​

UnitOfMeasurement

XDimension​

Gets or sets the XDimension of the barcode. (Inherited from Barcode)

public Nullable&ltfloat> XDimension { get; set; }
Public Property XDimension As Nullable(Of Single)

Property Value​

Nullable&ltfloat>

Methods​

Draw(Single, ImageFormat)​

Draw barcode image. (Inherited from Barcode)

public Byte[] Draw(float dpi, ImageFormat imageFormat)
Function Draw(dpi As Single, imageFormat As ImageFormat) As Byte()

Parameters​

Image resolution for barcode image.

Image format for barcode image.

Returns​

Image data as byte array.

Examples​

This example shows how to output the barcode image to a byte array.

Imports System
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

' Create a barcode object.
Dim barcode As Code11 = New Code11("12345678", 50)

' Save the barcode image to a byte array
Dim MyBarcodeData As Byte() = barcode.Draw(96, ImageFormat.Png)

End Sub
End Module
using System;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Code11 barcode = new Code11("12345678", 50);

// Save the barcode image to a byte array
byte[] barcodeData = barcode.Draw(96, ImageFormat.Png);

}
}

Draw(Single, Single, ImageFormat)​

Draw barcode image. (Inherited from Barcode)

public Byte[] Draw(float horizontalDpi, float verticalDpi, ImageFormat imageFormat)
Function Draw(horizontalDpi As Single, verticalDpi As Single, imageFormat As ImageFormat) As Byte()

Parameters​

Horizontal resolution for barcode image.

Vertical resolution for barcode image.

Image format for barcode image.

Returns​

Image data as byte array.

Examples​

This example shows how to output the barcode image to a byte array.

Imports System
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

' Create a barcode object.
Dim barcode As Code11 = New Code11("12345678", 50)

' Save the barcode image to a byte array
Dim MyBarcodeData As Byte() = barcode.Draw(96, 96, ImageFormat.Png)

End Sub
End Module
using System;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Code11 barcode = new Code11("12345678", 50);

// Save the barcode image to a byte array
byte[] barcodeData = barcode.Draw(96, 96, ImageFormat.Png);
}
}

Draw(String, Single, ImageFormat)​

Draw barcode image. (Inherited from Barcode)

public void Draw(string filePath, float dpi, ImageFormat imageFormat)
Sub Draw(filePath As String, dpi As Single, imageFormat As ImageFormat)

Parameters​

Input file path to save image.

Image resolution for barcode image.

Image format for barcode image.

Examples​

The following example will Draw a Codabar barcode image.

Imports System
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

'Create a barcode object.
Dim barcode As Codabar = New Codabar("A1234A", 100)

'Draw barcode image.
barcode.Draw("C:\barcode.png", 96, ImageFormat.Png)

End Sub
End Module
using System;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Codabar barcode = new Codabar("A1234A", 100);

// Draw barcode image.
barcode.Draw(@"C:\barcode.png", 96, ImageFormat.Png);

}
}

Draw(String, Single, Single, ImageFormat)​

Draw barcode image. (Inherited from Barcode)

public void Draw(string filePath, float horizontalDpi, float verticalDpi, ImageFormat imageFormat)
Sub Draw(filePath As String, horizontalDpi As Single, verticalDpi As Single, imageFormat As ImageFormat)

Parameters​

Input file path to save image.

Horizontal resolution for barcode image.

Vertical resolution for barcode image.

Image format for barcode image.

Examples​

The following example will Draw a Codabar barcode image.

Imports System
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

'Create a barcode object.
Dim barcode As Codabar = New Codabar("A1234A", 100)

'Draw barcode image.
barcode.Draw("C:\barcode.png", 96, 96, ImageFormat.Png)

End Sub
End Module
using System;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Codabar barcode = new Codabar("A1234A", 100);

// Draw barcode image.
barcode.Draw(@"C:\barcode.png", 96, 96, ImageFormat.Png);

}
}

DrawToBitmap(Single)​

Returns bitmap object of barcode image. (Inherited from Barcode)

public Bitmap DrawToBitmap(float dpi)
Function DrawToBitmap(dpi As Single) As Bitmap

Parameters​

Image resolution for barcode image.

Returns​

A value representing bitmap image object.

Examples​

TThis example shows how to output the barcode image as a Bitmap.

Imports System
Imports System.Drawing
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

' Create a barcode object.
Dim barcode As Ean8 = New Ean8("12345670")

' Save the barcode as a BitMap
Dim MyBarcodeBitmap As Bitmap = barcode.DrawToBitmap(96)

End Sub
End Module
using System;
using System.Drawing;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Ean8 barcode = new Ean8("12345670");

// Save the barcode as a BitMap
Bitmap MyBarcodeBitmap = barcode.DrawToBitmap(96);
}
}

DrawToBitmap(Single, Single)​

Returns bitmap object of barcode image. (Inherited from Barcode)

public Bitmap DrawToBitmap(float horizontalDpi, float verticalDpi)
Function DrawToBitmap(horizontalDpi As Single, verticalDpi As Single) As Bitmap

Parameters​

Horizontal resolution for barcode image.

Vertical resolution for barcode image.

Returns​

A value representing bitmap image object.

Examples​

TThis example shows how to output the barcode image as a Bitmap.

Imports System
Imports System.Drawing
Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()

' Create a barcode object.
Dim barcode As Ean8 = New Ean8("12345670")

' Save the barcode as a BitMap
Dim MyBarcodeBitmap As Bitmap = barcode.DrawToBitmap(96, 96)

End Sub
End Module
using System;
using System.Drawing;
using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Ean8 barcode = new Ean8("12345670");

// Save the barcode as a BitMap
Bitmap MyBarcodeBitmap = barcode.DrawToBitmap(96, 96);
}
}

Equals(Object)​

Determines whether the specified Object is equal to the current Object . (Inherited from Object)

public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean

Parameters​

The Object to compare with the current Object .

Returns​

true if the specified Object is equal to the current Object ; otherwise, false.

GetHashCode()​

Serves as a hash function for a particular type. (Inherited from Object)

public int GetHashCode()
Function GetHashCode() As Integer

Returns​

A hash code for the current Object .

GetOverflowDataMatrixBarcode()​

Gets a new instance of the DataMatrixBarcode class.

public DataMatrixBarcode GetOverflowDataMatrixBarcode()
Function GetOverflowDataMatrixBarcode() As DataMatrixBarcode

Returns​

Returns a DataMatrixBarcode object.

Examples​

The following example shows how to create the Data Matrix barcodes in cases where more than one barcode is required to represent the data.

Imports System
Imports ceTe.DynamicBarcode.Creator

Module MyModule
Sub Main()

Dim MyFileCount As Integer = 1

' Create Data Matrix barcode object.
Dim MyDataMatrixBarcode As DataMatrixBarcode = New DataMatrixBarcode("Lorem ipsum dolor sit amet, consectetur.", DataMatrixEncodingType.Ascii, DataMatrixSymbolSize.R16xC16)

Do
Dim MyTempDataMatrixBarcode As DataMatrixBarcode = Nothing

' Get the Overflow Data Matrix barcode.
MyTempDataMatrixBarcode = MyDataMatrixBarcode.GetOverFlowDataMatrixBarcode()

' Save the Data Matrix barcode as an image.
MyDataMatrixBarcode.Draw("MyDataMatrixBarcode" + MyFileCount.ToString() + ".png", 72, ImageFormat.Png)

MyDataMatrixBarcode = MyTempDataMatrixBarcode

MyFileCount += 1
Loop While Not MyDataMatrixBarcode Is Nothing
End Sub
End Module
using System;
using ceTe.DynamicBarcode.Creator;

class MyClass
{static void Main(){ int fileCount = 1;
// Create Data Matrix barcode object. DataMatrixBarcode dataMatrixBarcode = new DataMatrixBarcode("Lorem ipsum dolor sit amet, consectetur.", DataMatrixEncodingType.Ascii, DataMatrixSymbolSize.R16xC16);
do
{
DataMatrixBarcode tempDataMatrixBarcode = null;

// Get the Overflow Data Matrix barcode.
tempDataMatrixBarcode = dataMatrixBarcode.GetOverFlowDataMatrixBarcode();

// Save the Data Matrix barcode as an image.
dataMatrixBarcode.Draw("DataMatrixBarcode" + fileCount.ToString() + ".png", 72, ImageFormat.Png);

dataMatrixBarcode = tempDataMatrixBarcode;

fileCount++;
} while (dataMatrixBarcode != null);}
}

Remarks​

This method returns a new DataMatrixBarcode object that contains the remaining data that did not fit.

GetRecommendedQuietZone(Single, Single)​

Gets the recommanded quietzone of the barcode. (Inherited from Barcode)

public Margin GetRecommendedQuietZone(float horizontalDpi, float verticalDpi)
Function GetRecommendedQuietZone(horizontalDpi As Single, verticalDpi As Single) As Margin

Parameters​

The horizontal dpi of the barcode.

The vertical dpi of the barcode.

Returns​

The recommanded quietzone of the barcode.

GetRequiredSize(Single, Single)​

Returns the size required to display the full barcode. (Inherited from Barcode)

public Size GetRequiredSize(float horizontalDpi, float verticalDpi)
Function GetRequiredSize(horizontalDpi As Single, verticalDpi As Single) As Size

Parameters​

Resolution of barcode image.

Horizontal and vertical resolution of barcode image.

Returns​

A value representing the required size.

Examples​

The following example will show how to get size required to display the full barcode.

Imports System
Imports System.Drawing

Imports ceTe.DynamicBarcode.Creator

Module MyModule

Sub Main()
' Create a barcode object.
Dim barcode As Codabar = New Codabar("A1234A", 100)

' Get the SizeF object which contains Height and Width of a barcode.
Dim size As SizeF = barcode.GetRequiredSize(96, 96)
Dim width As Single = size.Width
Dim height As Single = size.Height

' Draw barcode image.
barcode.Draw("C:\barcode.png", 96, ImageFormat.Png)
End Sub
End Module
using System;
using System.Drawing;

using ceTe.DynamicBarcode.Creator;

class MyClass
{
static void Main()
{
// Create a barcode object.
Codabar barcode = new Codabar("A1234A", 100);

// Get the SizeF object which contains Height and Width of a barcode.
SizeF size = barcode.GetRequiredSize(96, 96);
float width = size.Width;
float height = size.Height;

// Draw barcode image.
barcode.Draw(@"C:\barcode.png", 96, ImageFormat.Png);
}
}

GetType()​

Gets the Type of the current instance. (Inherited from Object)

public Type GetType()
Function GetType() As Type

Returns​

The Type instance that represents the exact runtime type of the current instance.

ToString()​

Returns a String that represents the current Object . (Inherited from Object)

public string ToString()
Function ToString() As String

Returns​

A String that represents the current Object .

See Also​

ceTe.DynamicBarcode.Creator