.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Avapose > EAN-13 Barcode Introduction > EAN-13 Size Setting > EAN-13 Barcode Size Setting in C#

EAN-13 C# Size Setting

EAN-13 Barcode Size Setting, Generate & Create EAN-13 in C#, ASP.NET, VB.NET

A typical EAN-13 barcode symbology consists of a left quiet zone, a normal guard bar pattern, twelve symbol characters separated by a center guard bar pattern, another normal guard bar pattern and a right quiet zone.

As a result, the symbol width of a EAN-13 can be calculated with the formula:


EAN-13




W = ( 7C + 11 )X + 2Q


W: width of EAN-13 barcode image (including quiet zones)
X: width of EAN-13 narrowest bar; (X min = 1 pixel)
C: the number of encoded data chars for EAN-13, including the check digit; C =12.
Q: width of the quiet zone; Q > = 7X; Q (L) = 11X, Q (R) = 7X. For Avapose, default Q=10X.


C# Size Setting

With the formula above, there will be three ways to set the size of a EAN-13 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:
EAN13.X=1;
EAN13.Data = "147852369874";
EAN13.AutoResize=false;
The rest of barcode settings are in default value.
Here is the generated EAN-13 barcode:



Method 2. Setting the Barcode Width


Setting in C# generator

Steps:

  • Set the barcode width

  • Set AutoResize to true

  • Adjust other properties


Sample:
EAN13.BarcodeImageWidth=140;
EAN13.AutoResize=true;
EAN13.Data ="789456123456";
EAN3.BarcodeImageHeight=95;
The rest of barcode settings are in default value.
Here is the generated EAN-13 barcode:



According to the formula above, the maximum X dimension is 1 pixel for this EAN-13 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:
EAN13.X=2;
EAN13.BarcodeImageWidth=240;
EAN13.Data ="123698745632";
EAN13.AutoResize=false;
The rest of barcode settings are in default value.
Here is the generated EAN-13 barcode:



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 EAN-13 Generators will reset the barcode width to a minimum value according to the standard. Here is an example:


If you set in C# EAN-13 generator:
EAN13.X=2;
EAN13.BarcodeImageWidth=200;
EAN13. Data ="147896325698";
EAN13.AutoResize=false;
The rest of barcode settings are in default value


According to the formula above,
W = ( 7C + 11 ) X + 2Q
//X=2pixel, Q=10X, C=12,
Wmin= (12*7+11)*2+2*10*2
=230 pixel

However, the W (200 pixel) you have set in C# generator is less than the minimum barcode width (230pixel), so the generator will automatically reset it to 230 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.


For instance,
if you set in your C # generator:
EAN13.X=4;
EAN13.W=300;
EAN13; Data ="AB";
The rest of barcode settings are in default value.


According to the formula,
W=(C+2)(3N+6)X+(C+1)I+2Q 
//X=4pixel, C=2, N=2(default),I=1X=4
Qmin=10*2=20 pixel
Wmin= (2+2)(3*2+6)*4+(2+1)*4+80
= 284 pixel

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

EAN-13 barcode field configuration in C# for various barcode solutions