.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader

EAN-8 C# Size Setting

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

A typical EAN-8 barcode symbology consists of a left quiet zone, a normal guard bar pattern, eight data characters divided by a center guard bar pattern, another normal guard bar pattern and then the right quiet zone.

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


EAN-8




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


X: width of a narrow element
C: number of encoded data chars (check digit included if used)
N: wide/narrow bar ratio (2<=N<=3)
Q: width of the quiet zone (Qmin=10X)
W: barcode width of EAN-8


C# Size Setting

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

Method 2. Setting the Barcode Width


Setting in C# generator

Steps:

  • Set the barcode width

  • Set AutoResize to true

  • Adjust other properties


Sample:
EAN8.BarcodeImageWidth=270;
EAN8.AutoResize=true;
EAN8.Data ="2976131";
EAN8.BarcodeImageHeight=95;
The rest of barcode settings are in default value.
Here is the generated EAN8 barcode:



According to the formula above, the maximum X dimension is 2 pixel for this EAN-8 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:
EAN8.X=3;
EAN8.BarcodeImageWidth=270;
EAN8.AutoResize=false;
EAN8.Data ="3692581";
The rest of barcode settings are in default value.
Here is the generated EAN-8 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-8 Generators will reset the barcode width to a minimum value according to the standard. Here is an example:


If you set in C# EAN-8 generator:
EAN8.X=2;
EAN8. BarcodeImageWidth =140;
EAN8. Data ="1472583";
EAN8.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=8
(including checksum automatically calculated),
Wmin= (8*7+11)*2+2*10*2
=174 pixel

However, the W (140 pixel) you have set in C# generator is less than the minimum barcode width (174pixel), so the generator will automatically reset it to 174 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:
EAN8.X=2;
EAN8. BarcodeImageWidth =200;
EAN8; Data ="7894561";
EAN8.AutoResize=false;
The rest of barcode settings are in default value.


According to the formula,
W = ( 7C + 11 ) X + 2Q
//X=2pixel, Qmin=10*2=20 pix, C=8
(including checksum automatically calculated),
Wmin= (8*7+11)*2+2*10*2
=174 pixel

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

EAN-8 barcode size custom in C# for various barcode solutions