.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Avapose > GS1 128 Barcode Introduction > GS1 128 Size Setting > GS1 128 Barcode Size Setting in C#

GS1 128 C# Size Setting

Barcode Generator Size Setting, generate & create Data Matrix in C#, ASP.NET, VB.NET applications

The components of GS1 128 barcode include Quiet zone, Start pattern, Data characters, Symbol check character, Stop character and Quiet zone.

As a result, the symbol width of an GS1 128 can be calculated with the formula:


GS1 128




W = 2Q + 46X + 11NX

W : the symbol width of GS1-128
Q : the width of the quiet zone; Q min=10X
X : the width of a module bar; X min=1 pixel
N : the number of symbol character (double density for numeric data in Code C)


C# Size Setting



With the formula above, there will be three ways to set the size of an GS1 128 image in C#. Here are the methods and respective examples.

Method 1. Setting the X Dimension


Setting in C# generator

Steps:

  • Set the X dimension

  • Set AutoResize to false

  • Adjust other properties


Sample:
EAN128.Data = "(01)2233";
EAN128.X = 3;
EAN128.AutoResize = false;
Other properties: default;
The generated GS1-128 image is:




Method 2. Setting the Barcode Width



Setting in C# generator

Steps:

  • Set the barcode width

  • Set AutoResize to true

  • Adjust other properties


Sample:
EAN128.BarcodeImageWidth = 250;
EAN128.BarcodeImageHeight = 75;
EAN128.AutoResize = true;
Other properties: default;
The generated GS1-128 image is:


According to the formula above, the maximum X dimension is 2 pixel for this GS1 128 barcode.


Method 3. Setting both X Dimension and Symbol Width



Setting in C# generator

Steps:

  • Set the X dimension

  • Set the barcode width

  • Set AutoResize to false

  • Adjust other properties


Sample:
EAN128.Symbology = Symbology.Code128Auto;
EAN128.Data = "(01)2233";
EAN128.X = 1;
EAN128.BarcodeImageWidth = 130;
EAN128.AutoResize = false;
Other properties: default;
The generated GS1-128 image is:





Attention
: Please note that once you have set an X dimension, there will always be a minimum barcode width as calculated from the calculation above. Therefore, if the W you have set is less than the minimum value, Avapose gs1 128 Generators will reset the barcode width to a minimum value according to the standard. Here is an example:


If you set in C# EAN 128 generator:
EAN128.X=2;
EAN128.W=160;
EAN; Data ="(01)2233";
The rest of barcode settings are in default value

According to the formula above,
W = 2Q + 46X + 11NX
//X=2pixel, N=3 (default), Q min=10*2=20 pixel
W min = 40+92+66
W min=198pixel

However, the W (160 pixel) you have set in C# generator is less than the minimum barcode width (198pixel), so the generator will automatically reset it to 198 pixel according to standard. Here is the generated barcode image:

On the other hand, if you set a barcode width larger than the minimum W calculated by the formula, extra spaces will be added to either side of the quiet zones.


if you set in your C # generator:
EAN128.X=4;
EAN128.W=426;
EAN128; Data ="(01)2233";
The rest of barcode settings are in default value.

According to the formula,
W = 2Q + 46X + 11NX
//X=4pixel, N=3 (default), Q min=10*4=40 pixel
W min = 2*40 + 46*4+11*3*4
=396pixel

Now your W setting is 426 pixel, which is larger than the minimum width, so an extra 40 pixel will be added to both side of the quiet zone. Here is the barcode image:

GS1-128(UCC/EAN128) barcode size custom in C# for various barcode solutions