A typical UPC-E barcode symbology consists of a left quiet zone, a normal guard bar pattern, six symbol chars, a special guard bar pattern and a right quiet zone.
As a result, the symbol width of a EAN-8 can be calculated with the formula:
UPC-E

|
W = ( C * 7 + 9 ) X + 2Q
|
W: width of UPC-E barcode image (including quiet zones)
X: width of UPC-E narrowest bar; (X min = 1 pixel)
C: the number of encoded data chars for UPC-E, including the check digit; C =6.
Q: width of the quiet zone; Q>=7X; For Avapose, default Q=10X.
|
With the formula above, there will be three ways to set the size of a UPC-E 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:
UPCE.X=2;
UPCE.Data = "123456";
UPCE.AutoResize=false;
The rest of barcode settings are in default value.
Here is the generated UPC-E barcode:

|
Method 2. Setting the Barcode Width
Setting in C# generator
Steps:
- Set the barcode width
- Set AutoResize to true
- Adjust other properties
|
Sample:
UPCE.BarcodeImageWidth=150;
UPCE.AutoResize=true;
UPCE.Data ="565434";
UPCE.BarcodeImageHeight=95;
The rest of barcode settings are in default value.
Here is the generated UPC-E barcode:

According to the formula above, the maximum X dimension is 2 pixel for this UPC-E 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:
UPCE.X=3;
UPCE.BarcodeImageWidth=220;
UPCE.AutoResize=false;
UPCE.Data ="077533";
The rest of barcode settings are in default value.
Here is the generated UPC-E 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 UPC-E 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:
UPCE.X=4;
UPCE. BarcodeImageWidth =230;
UPCE. Data ="343542";
UPCE.AutoResize=false;
The rest of barcode settings are in default value
|
According to the formula above,
W = ( C * 7 + 9 ) X + 2Q
//X=4pixel, Q=10X, C=6
Wmin= (6*7+9)*4+2*10*4
=284 pixel
|
However, the W (230 pixel) you have set in C# generator is less than the minimum barcode width (284pixel), so the generator will automatically reset it to 284 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:
UPCE.X=4;
UPCE. BarcodeImageWidth =300;
UPCE; Data ="345542";
UPCE.AutoResize=false;
The rest of barcode settings are in default value.
|
According to the formula,
W = ( C * 7 + 9 ) X + 2Q
//X=4pixel, Qmin=10*4=40 pixel , C=6
Wmin= (6*7+11)*4+2*10*4
=284 pixel
|
Now your W setting is 300 pixel, which is larger than the minimum width, so an extra 8 pixel will be added to both side of the quiet zone. Here is the barcode image:
UPC-E barcode size setting in C# for related barcode solutions