Setting GS1-128 Barcode Size in C#

Controling GS1-128 Barcode Size in C#

OnBarcode provides professional GS1-128 generation components for ASP.NET, C#, VB.NET applications.

GS1-128 Structure

  • W : he symbol width of GS1-128
  • Q : the width of the quiet zone; Qmin=10X
  • X : the width of a module bar; Xmin=1 pixel
  • N : the number of symbol character (double density for numeric data in Code C)in the above example, N=20 for Code set A/B, N=10 for Code set C.



Setting GS1-128 Barcode Size in C#

Basic information you should know

The width W of a GS1-128 symbol, including quiet zones, can be calculated from the following expression:

W = 2Q + 46X + 11NX

GS1-128 barcode height is user-defined. So you can adjust the barcode height through Top and Bottom Margin settings in C# GS1-128 generator according to your applications.


Three Situations for Setting GS1-128 Barcode Size in C#

Setting GS1-128 barcode size in C# GS1-128 Generator may have three situations:

Situation 1:

If you want to create a GS1-128 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# GS1-128 generator:
ean128.X = 2;
ean128.AutoResize = false;
Other properties: default;
The generated GS1-128 image is:


Situation 2:

If you want to generate a GS1-128 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# GS1-128generator:
ean128.BarcodeWidth = 250;
ean128.BarcodeHeight = 60;
ean128.AutoResize = true;
Other properties: default;
The generated GS1-128 image is:

In the above GS1-128 image, the bar module (X) is 2 pixel, which is the maximum bar module.


Situation 3:

If you want to generate a GS1-128 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# GS1-128 generator:
ean128.X = 1;
ean128.BarcodeWidth = 120;
ean128.AutoResize = false;
Other properties: default;
The generated GS1-128 image is:


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

GS1-128 minimum barcode image width (W min) is:

= 66 X + 11 NX

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:

ean128.X = 3;
ean128.BarcodeWidth = 200;
ean128. Data = "(00)1234";
ean128.AutoResize = false;
Other properties: default;
Then GS1-128 barcodes minimum width (Wmin) is:
= 66*3+11*3*3
= 297 pixel

Now your BarcodeWidth setting is 200 pixel, which is less than the minimum barcode width, the component generated GS1-128 image will be like this.


If your BarcodeWidth setting is 320 pixel, which is larger than the minimum barcode width (297 pixel), the generated GS1-128 image will be like below. And extra 11.5 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.