The components of PDF-417 barcode are Quiet zone, Start character, Data characters, Check digit, Stop character and Quiet zone.
As a result, the symbol width of an PDF-417 can be calculated with the formula:
PDF-417

|
W = 2 Q (Hori) + 69X + 17C X
H = 2Q(vertical) + R Y (Y >= 3X, Q >= 2X)
|
W : the width of PDF-417
Q : the width of the quiet zone; Q min=2X
R : umber of rows in the symbol (3<=R<=90)
C : number of columns in the symbol in the data region (excluding start, stop and row indicator codewords)(1<=C<=30)
X : the width of a module bar; Xmin=1 pixel
Y : module height (also called row height) (Ymin=3X)
H : height of symbol |
With the formula above, there will be three ways to set the size of an PDF-417 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:
PDF417.Symbology = Symbology.PDF417;
PDF417.Data = "123456";
PDF417.X = 2;
PDF417.AutoResize = false;
Other properties: default;
The generated PDF-417 image is:

|
Method 2. Setting the Barcode Width
Setting in C# generator
Steps:
- Set the barcode width and height
- Set AutoResize to true
- Adjust other properties
|
Sample:
PDF417.Symbology = Symbology.PDF417;
PDF417.Data = "123456";
PDF417.BarcodeImageWidth = 400;
PDF417.BarcodeImageHeight = 40;
PDF417.AutoResize = true;
Other properties: default;
The generated PDF-417 image is: :

According to the formula above, the maximum X dimension is 3 pixel for this PDF-417 barcode.
|
Method 3. Setting both X Dimension, Symbol height and Symbol Width
Setting in C# generator
Steps:
- Set the X dimension
- Set the barcode width and height
- Set AutoResize to false
- Adjust other properties
|
Sample:
PDF417.Symbology = Symbology.PDF417;
PDF417.Data = "123456";
PDF417.X = 2;
PDF417.BarcodeImageWidth = 380;
PDF417.BarcodeImageHeight = 35;
PDF417.AutoResize = false;
Other properties: default;
The generated PDF-417 image is:

|
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 PDF-417 Generators will reset the barcode width to a minimum value according to the standard. Here is an example:
If you set in C# PDF-417 generator:
PDF417.X=4;
PDF417.W=500;
PDF417; Data ="123456";
The rest of barcode settings are in default value
|
According to the formula above,
W = 2 Q(Hori) + 69X + 17C X
//X=4pixel, Q= 0, C=
W min= 2*0+69*4+17*4*5
=616pixel
H = 2Q(vertical) + R Y
=2*0+3*3*4
=36 pixel
|
However, the W (500 pixel) you have set in C# generator is less than the minimum barcode width (616pixel), so the generator will automatically reset it to 616 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.
if you set in your C # PDF-417 generator:
PDF417.X=3;
PDF417.W=500;
PDF417; Data ="123456";
The rest of barcode settings are in default value.
|
According to the formula,
W = 2 Q(Hori) + 69X + 17C X
//X=4pixel, Q= 0, C=5
W min= 2*0+69*3+17*3*5 =207+255
=462pixel
H = 2Q(vertical) + R Y
=2*0+3*3*3
=27 pixel
|
Now your W setting is 500 pixel, which is larger than the minimum width, so an extra 38 pixel will be added to both side of the quiet zone. Here is the barcode image:
PDF417 2D barcode size setting in C# for various barcode solutions