Setting PDF-417 Barcode Size in C#

Creating and Customizing PDF417 Barcodes in C#

OnBarcode provides explanation of how to set PDF417 image size in Java, .NET, Android developments. And customers are entitled to adjust PDF417 barcode size using the products below.



How to generate, print barcode using .NET, Java sdk library control with example project source code free download:

PDF-417 Generator Components

PDF-417 Scanner Components

PDF-417 Generator & Scanner Software


PDF-417 Structure

  • W : the width of PDF-417
  • Q : the width of the quiet zone; Qmin = 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



Setting PDF-417 Barcode Size in C#

Basic information you should know

The width W of a PDF417 symbol, including quiet zones can be calculated from the following expression:

W = 2Q(Hori) + 69X + 17CX
The Height of a PDF417 symbol, including quiet zones can be calculated from the following expression:

H = 2Q(Vertical) + RY         (Y>=3X,Q>=2X)


Three Situations for Setting PDF417 Barcode Size in C#

Setting PDF417 barcode size in C# PDF417 Generator may have three situations:

Situation 1:

If you want to create a PDF417 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# PDF417 generator:
pdf417.X = 3;
pdf417.AutoResize = false;
Other properties: default;
The generated PDF 417 image is:


Situation 2:

If you want to generate a PDF417 with a fixed barcode image width (W)and height (H), 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 fixed value of barcode image height (H).
  • Set the AutoResize option to be true.
  • Customize other properties.
Eg2. Set in C# PDF 417 generator:
pdf417.BarcodeWidth = 600;
pdf417.BarcodeHeight = 50;
pdf417.AutoResize = true;
Other properties: default;
The generated PDF417 image is:

In the above PDF 417 image, the bar module (X) is 3 pixel, which is the maximum bar module.


Situation 3:

If you want to generate a PDF417 with minimum X and a fixed barcode image width (W) and height (H), please do as below:
  • Set the values of minimum X and barcode image width (W)and height (H).
  • Set the AutoResize option to be false.
  • Customize other properties.
Eg3. Set in C# PDF417 generator:
pdf417.X = 2;
pdf417.BarcodeWidth = 350;
pdf417.BarcodeHeight = 38;
pdf417.AutoResize = false;
Other properties: default;
The generated PDF417 image is:


Note that, once you have set bar module (X) value, there will be a minimum barcode image width and height defined by PDF417 specification.

PDF417 minimum barcode image width (W min) is:

= 2Q + 69X + 17CX

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:

pdf417.X = 4;
pdf417.BarcodeWidth = 400;
pdf417.BarcodeHeight = 20;
pdf417.AutoResize = true;
Other properties: default;

Then PDF417 barcode minimum width (W min)(without quiet zone by default) is:
= 2*0 + 69*4 + 17*4*5
= 616 pixel

And the PDF417 barcode minimum height (Hmin) (without quiet zone by default) is
= 2*0 + 3*3*4
= 36 pixel




Now your BarcodeWidth setting is 280 pixel, which is less than the minimum barcode width.And the Barcode Height setting is 20 pixel, which is less than the minimum barcode height. The component will resize the barcode image to the minimum size, so generated PDF417 image will be like this. the component generated PDF417 image will be like this.


If your BarcodeWidth setting is 650 pixel, and your BrcodeHeight 50 pixel, which are larger than the minimum barcode width (616 pixel) and the 36 pixel barcode height, the generated PDF417 image will be like below, with an extra 19 pixel space added to horizontal margins, and an extra 7 pixel space added to the vertical margins. ,






OnBarcode is a market-leading provider of barcode generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides high quality tutorials and guides for various linear, 2d barcode information, such as C# Barcode, QR Code C#, QR Code VB.NET, QR Code ASP.NET, QR Code .NET, ASP.NET Barcode. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.