Setting Interleaved 2 of 5 Barcode Size in C#
Adjusting Interleaved 2 of 5 Barcode Size in C#
OnBarcode provides mature, reliable
Interleaved 2 of 5 generation components for ASP.NET, C#, VB.NET, Java, iOS developments and various Report applications.
How to generate, print barcode using .NET, Java sdk library control with example project source code free download:
Interleaved 2 of 5 Structure
- W : the width of Interleaved 2 of 5.
- X : the width of Interleaved 2 of 5 narrow bar; X min = 1 pixel.
- N : the wide bar to narrow bar ratio; from 2.0 to 3.0, inclusive.
- P : the number of character pairs.
- Q : the width of the quiet zone; minimum is 10X.
Setting Interleaved 2 of 5 Barcode Size in C#
Basic information you should know
Interleaved 2 of 5 barcode width, W (measured in pixel), including quiet zones, can be computed from the expression below:
W = [ P ( 4N + 6 ) +N + 6 ) ] X + 2Q
Three Situations for Setting Interleaved 2 of 5 Barcode Size in C#
Setting Interleaved 2 of 5 barcode size in C# Interleaved 2 of 5 Generator may have three situations:
Situation 1:
If you want to create an Interleaved 2 of 5 with a minimum X, please do as below:
- Set the minimum value of X.
- Set the AutoResize option to be false.
- Customize other properties.
Eg1. Set in C# Interleaved 2 of 5 generator:
interleaved 2 of 5.X = 3;
interleaved 2 of 5.AutoResize = false;
interleaved 2 of 5.N = 2;
Other properties: default;
The generated Interleaved 2 of 5 image is:
Situation 2:
If you want to generate an Interleaved 2 of 5 with a fixed barcode image width (W), and try to draw maximum barcode module (X) as possible, please do as follows:
- Set the fixed value of barcode image width (W).
- Set the AutoResize option to be true.
- Customize other properties.
Eg2. Set in C# Interleaved 2 of 5 generator:
interleaved 2 of 5.BarcodeWidth = 290;
interleaved 2 of 5.BarcodeHeight = 60;
interleaved 2 of 5.N = 2;
interleaved 2 of 5.AutoResize = true;
Other properties: default;
The generated Interleaved 2 of 5 image is:
In the above Interleaved 2 of 5 image, the bar module (X) is 2 pixel, which is the maximum bar module.
Situation 3:
If you want to generate an Interleaved 2 of 5 with minimum X and fixed barcode image width (W), please do as below:
- Set the values of minimum X and barcode image width (W).
- Set the AutoResize option to be false.
- Customize other properties.
Eg3. Set in C# Interleaved 2 of 5 generator:
interleaved 2 of 5.X = 3;
code39.BarcodeWidth = 260;
interleaved 2 of 5.N = 2;
code39.AutoResize = false;
Other properties: default;
The generated Interleaved 2 of 5 image is:
Note that, once you have set bar module (X) value, there will be a minimum barcode image width defined by Interleaved 2 of 5 ISO specification.
Interleaved 2 of 5 minimum barcode image width (W min) is:
= [ P ( 4 * 2 + 6 ) + 2 + 6 ] X + 2 * 10X
So if your BarcodeWidth value is less than the minimum barcode width, the barcode generator component will reset BarcodeWidth value to the minimum barcode width value.
For example, you set:
code39.X = 3;
code39.BarcodeWidth = 260;
code39. Data = "1234567890";
code39.P = 5;
code39.AutoResize = false;
Other properties: default;
Then Interleaved 2 of 5 barcode minimum width (W min) is:
= [ 5 * ( 4 * 2 + 6 ) + 2 + 6 ) X + 2 * 10X       //P = 5
= 78 X + 20 X
= 98 X       //X = 3
= 294 pixel