Code 39 Barcode Dimension Size using C#
Developer Guide for Code 39 barcode image dimension size (width & height) in C#
Code 39 Size Setting Instruction
Code 39 Size Setting
OnBarcode products enable users to adjust
Code 39 image size during barcode generation. And Code 39 barcode size setting is supported by the following OnBarcode products:
Code 39 Structure
- W : the width of Code 39.
- Q : the width of the quiet zone; Q min = 10X.
- I : the width of the intercharacter gap; this is a multiple of X; I min = X.
- C : the number of encoded Code 39 data characters (including module 43 check character if used).
- X : the width of Code 39 narrow bar; X min = 1 pixel.
- N : the wide bar to narrow bar ratio; from 2.0 to 3.0, inclusive.
Code 39 Barcode Width
The Code 39 barcode width, W (measured in pixel), including quiet zones, can be calculated from the following expression:
W = ( C + 2 ) ( 3N + 6 ) X + ( C + 1 ) I + 2Q
Then the minimum value of W can be calculated as below:
N min = 2 , I min = 1 , Q min = 10X .
W min = ( C + 2 ) ( 3 * 2 + 6 ) X + ( C + 1 ) X + 2 * 10X
= ( 12C + 24 + C + 1 + 20 ) X
= ( 13C + 45 ) X
If, X min = 1 , W min = 13C + 45
Eg. Code 39 data = " 1A " , C = 2 .
W min = 13C + 45 = 26 + 45 = 71 pixel
Code 39 Barcode Height
There are no rigid requirements for the height of Code 39 in ISO/IEC 16388:2007(E). The recommended minimum height for manual scanning is 5.0mm or 15 % of Code 39 width (excluding quiet zones), whichever is greater.
Our Code 39 generators will set the height of Code 39 automatically. Meanwhile, customers may adjust the barcode height through Top and Bottom Margin settings.
OnBarcode provides details of
Code 39 Barcode Generator in C#.
Setting Code 39 Barcode Size in C#
Basic information you should know
Code 39 barcode width, W (measured in pixel), including quiet zones, can be computed from the expression below:
W = ( C + 2 ) ( 3N + 6 ) X + ( C + 1 ) I + 2Q
Code 39 barcode height is user-defined. So you can adjust the barcode height through Top and Bottom Margin settings in C# Code 39 generator according to your applications.
Three Situations for Setting Code 39 Barcode Size in C#
Setting Code 39 barcode size in C# Code 39 Generator may have three situations:
Situation 1:
If you want to create a Code 39 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# Code 39 generator:
code39.X = 3;
code39.AutoResize = false;
code39.I = code39.X;
Other properties: default;
The generated Code 39 image is:
Situation 2:
If you want to generate a Code 39 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# Code 39 generator:
code39.BarcodeWidth = 250;
code39.BarcodeHeight = 60;
code39.AutoResize = true;
code39.I = code39.X;
Other properties: default;
The generated Code 39 image is:
In the above Code 39 image, the bar module (X) is 2 pixel, which is the maximum bar module.
Situation 3:
If you want to generate a Code 39 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# Code 39 generator:
code39.X = 2;
code39.BarcodeWidth = 280;
code39.AutoResize = false;
code39.I = code39.X;
Other properties: default;
The generated Code 39 image is:
Note that, once you have set bar module (X) value, there will be a minimum barcode image width defined by Code 39 ISO specification.
Code39 minimum barcode image width (W min) is:
= ( C + 2 ) ( 3 * 2 + 6 ) X + ( C + 1 ) X + 2 * 10 X
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 = 280;
code39.I = 1;
code39. Data = "12345";
code39.AutoResize = false;
Other properties: default;
Then Code 39 barcode minimum width (W min) is:
= ( 5 + 2 ) ( 3 * 2 + 6 ) X + ( 5 + 1 ) X + 2 * 10X       //C = 5
= 7 * 12 X + 26 X
= 110 X       //X = 3
= 330 pixel
Now your BarcodeWidth setting is 280 pixel, which is less than the minimum barcode width, the component generated code 39 image will be like this.
If your BarcodeWidth setting is 380 pixel, which is larger than the minimum barcode width (280 pixel), the generated code 39 image will be like below. And extra 50 pixel space has been added to the left and right side of barcode image.