.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Avapose > Interleaved 2 of 5 Introduction > Interleaved 2 of 5 Size Setting > Interleaved 2 of 5 Size Setting in C#

Interleaved 2 of 5 C# Size Setting

Interleaved 2 of 5 Generator Size Setting, Generate & Create Barcode in C#, ASP.NET, VB.NET

A typical Interleaved 2 of 5 barcode symbology consists of: leading quiet zone, start pattern, one or more pairs of symbol characters to represent data (including optional symbol check character), stop pattern, and a trailing quiet zone.

As a result, the symbol width of an Interleaved 2 of 5 can be calculated with the formula:

Interleaved 2 of 5




W
= [ P ( 4N + 6 ) + N + 6 ] X + 2Q


X: width of a narrow element
P: number of data pairs
N: wide/narrow ratio (2<=N<=3)
Q: width of the quiet zone (Qmin=10X)
W: barcode width


C# Size Setting



With the formula above, there will be three ways to set the size of an Interleaved 2 of 5 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:
Interleaved2of5.X=3;
Interleaved2of5.Data = "9527";
Interleaved2of5.AutoResize=false;
The rest of barcode settings are in default value.
Here is the generated Interleaved 2 of 5 barcode:



Method 2. Setting the Barcode Width


Setting in C# generator

Steps:

  • Set the barcode width

  • Set AutoResize to true

  • Adjust other properties


Sample:
Interleave2of5.W=240;
Interleaved2of5.Data ="4546";
Interleaved2of5.AutoResize=true;
The rest of barcode settings are in default value.
Here is the generated Interleaved 2 of 5 barcode:


According to the formula above, the maximum X dimension is 4 pixel for this Interleaved 2 of 5 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


Interleaved2of5.X=2;
Interleaved2of5.BarcodeImageWidth=120;
Interleaved2of5.AutoResize=false;
Interleaved2of5.Data ="4488";
The rest of barcode settings are in default value.
Here is the generated Interleaved 2 of 5 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 Interleaved 2 of 5 Generators will reset the barcode width to a minimum value according to the standard. Here is an example:


If you set in C# Interleaved 2 of 5 generator:
Interleaved2of5.X=2;
Interleaved2of5.W=100;
Interleaved2of5; Data ="779922";
The rest of barcode settings are in default value

According to the formula above,
W = [ P ( 4N + 6 ) + N + 6 ] X + 2Q
//X = 2pixel, P = 3, N = 2(default),
Qmin = 10*2 = 20 pixel
Wmin = [ 3 ( 4 * 2 + 6 ) + 2 + 6 ] * 2 + 2 * 20
         =140pixel

However, the W (100 pixel) you have set in C# generator is less than the minimum barcode width (140pixel), so the generator will automatically reset it to 140 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:
Interleaved2of5.X=4;
Interleaved2of5.W=260;
Interleaved2of5; Data ="7654";
The rest of barcode settings are in default value.

According to the formula,
W = [ P ( 4N + 6 ) + N + 6 ] X + 2Q
//X = 4pixel, P = 2, N = 2(default),
Qmin = 10 * 2 = 20 pix
Wmin = [ 2 * ( 4 * 2 + 6 ) + 2 + 6 ] * 4 + 2 * 20
          = 224 pixel

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

Interleaved 2 of 5 barcode size custom in C# for various barcode solutions