Setting Data Matrix Barcode Size in C#

Data Matrix Barcode Size in C#

OnBarcode offers professional Data Matrix generation and recognization components for Java, .NET, Android, iOS developments and some reporting applications. Besides, Data Matrix image size is supported by these barcode components.

Data Matrix Barcode Generation Components

Data Matrix Barcode Reader Controls

Data Matrix Barcode Generator & Reader Softwares



Data Matrix Structure

  • X : the width of a module bar; Xmin=1 pixel
  • Q : the width of the quiet zone; Qmin=X
  • data regions : consisting of square modules set out in a regular array
  • finder pattern : two solid adjacent borders in an "L" shape (width=X)
  • timing pattern : other two borders consisting of alternating dark and light modules
  • alignment pattern : for larger symbols (start with 32x32) to separate data regions (=2X)



Setting Data Matrix Barcode Size in C#

Basic information you should know

The width W of a Data Matrix symbol, including quiet zones, can be calculated from the following expression:

W = M1X + 2 Q

(M1 stands for the larger number in the Format Mode (Symbol Size) you have chosen, eg1.If 12x12, M1=12; eg2. If 8x32, M1=32.)
Quiet zone: The minimum quiet zone is equal to X on all four sides.


Three Situations for Setting Data Matrix Barcode Size in C#

Setting Data Matrix barcode size in C# Data Matrix Generator may have three situations:

Situation 1:

If you want to create a Data Matrix with a minimum X, please do as below:
  • Set the minimum value of X.
  • Set the AutoResize option to be false.
  • Customize other properties.
Eg1. Set in C# Data Matrix generator:
datamatrix.Data = "123456";
datamatrix.X=5;
datamatrix.LeftMargin = 5;
datamatrix.RightMargin = 5;
datamatrix.TopMargin = 5;
datamatrix.AutoResize =false;
Other properties: default;
The generated Data Matrix image is:


Situation 2:

If you want to generate a Data Matrix with a fixed barcode image width (W), and try to draw maximum barcode module (X) as possible, please do as follows:
  • Set the fixed value of barcode image width (W).
  • Set the AutoResize option to be true.
  • Customize other properties.
Eg2. Set in C# Data Matrix generator:
datamatrix.BarcodeWidth=150;
datamatrix.AutoResize =true;
Other properties: default;
The generated Data Matrix image is:

In the above Data Matrix image, W=MX+2Q Q>=X, so maximum bar module is (X) is 12 pixel, which is the maximum bar module.


Situation 3:

If you want to generate a Data Matrix with minimum X and fixed barcode image width (W), please do as below:
  • Set the values of minimum X and barcode image width (W).
  • Set the AutoResize option to be false.
  • Customize other properties.
Eg3. Set in C# Data Matrix generator:
datamatrix.X=10;
(set the margins on all four sides to be 10)
datamatrix.BarcodeWidth=120;
datamatrix.BarcodeHeight=120;
Other properties: default;
The generated Data Matrix image is:


Note that, once you have set bar module (X) value, there will be a minimum barcode image width defined by Data Matrix specification.

Data Matrix minimum barcode image width (W min) is:

= MX + 2 X

So if your BarcodeWidth value is less than the minimum barcode width, the barcode generator component will reset BarcodeWidth value to the minimum barcode width value.

For example, you set:

code39.X = 10;
datamatrix.BarcodeWidth=100;
datamatrix.BarcodeHeight=100;
datamatrix. Data = "123456";
datamatrix.AutoResize = true;
Other properties: default;
Then Data Matrix barcode minimum width (W min) is:
= 10*10+2*10
= 120 pixel

Now your BarcodeWidth setting is 100 pixel, which is less than the minimum barcode width, the component generated Data Matrix image will be like this.

>

If your BarcodeWidth setting is 150 pixel, which is larger than the minimum barcode width (120 pixel), the generated Data Matrix image will be like below. And extra 15 pixel space has been added to the left and right side of barcode image.






OnBarcode is a market-leading provider of barcode 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 high quality tutorials and guides for various linear, 2d barcode information, such as C# Barcode, QR Code C#, QR Code VB.NET, QR Code ASP.NET, QR Code .NET, ASP.NET Barcode. 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.