In this tutorial, developers will learn how to scan and read 2D PDF417 barcode data from images in C# and VB.NET ASP.NET web applications, as well as in Windows Forms and WPF desktop applications.
Scan standard PDF 417 and Macro PDF417 barcode images.
Support for multiple image formats, including TIFF, BMP, JPEG, GIF, and PNG.
Scan the entire image area or a specified region.
Retrieve scanned barcode result details, including barcode data, coverage area, and rotation.
Install .NET PDF-417 Barcode Reader & Scanner
Add BarcodeLib.BarcodeReader.dll to your .NET project reference.
Scan & Read PDF-417 Barcodes in C#.NET
Scan and read PDF-417 barcode in C# is an easy and simple task. One line of C# code finishes the job.
The above C# code will get all PDF-417 barcodes in image file "pdf417-barcode.gif".
Scan & Read PDF-417 Barcodes in VB.NET
Scan and read PDF-417 barcode in VB.NET is an easy and simple task. One line of vb.net code finishes the job.
Dim datas() AsString = BarcodeReader.read("c:/pdf417-barcode.gif", BarcodeReader.PDF417)
The above VB.NET code will get all PDF-417 barcodes in image file "pdf417-barcode.gif".
Optimize PDF-417 Barcode Reading Performance in C#.NET & VB.NET
You can customize our .NET barcode reader component, to improve PDF-417 barcode reading speed, when you are scanning large image size (like 4mb per image).
Set maxOneBarcodePerPage to true, if there is maximum one barcode per image or per page in tiff or pdf document. If maxOneBarcodePerPage is true, the .net barcode reader library will stop scanning the barcode immediately, once detects one barcode. If maxOneBarcodePerPage is false (default value), the library will use total 5 algorithms and each will scan the whole image from 4 directions.
Scan the partial image instead of the whole file. If the barcode is always located one specified area in the image, you can set and let the library scan that area only. And it will reduce lots of scanning time, CPU and memory usage. You just specify the left top point and right bottom point of the area (the point X, Y values are expressed in percentage of the whole image, so image most left top point is (0%, 0%), and most right bottom point is (100%, 100%)).
The following C# code explains how to scan top 20% of the image and bottom 20% of the image.
OptimizeSetting setting = new OptimizeSetting();
setting.setMaxOneBarcodePerPage(true);
ScanArea top20 = new ScanArea(new PointF(0.0F, 0.0F), new PointF(100.0F, 20.0F));
ScanArea bottom20 = new ScanArea(new PointF(0.0F, 80.0F), new PointF(100.0F, 100.0F));
List<ScanArea> areas = new List<ScanArea>(); areas.Add(top20); areas.Add(bottom20);
Macro PDF417 provides a mechanism to split a large data file into blocks represented by multiple PDF417 symbols. Each Macro PDF417 symbol contains additional control information to enable reconstruction of the original data, regardless of the order in which symbols are scanned.
Key properties of Macro PDF 417:
File ID: All symbols with the same File ID belong to the same data message.
Segment Index: Order of the segment (first segment index is 0).
Is Last Segment: Indicates whether the current symbol is the last segment.
The following steps and code examples demonstrate how to extract Macro PDF417 information using the C# and VB.NET Barcode Reader library.
Use BarcodeScanner.ScanInDetails() to retrieve all PDF417 barcode information from an image.
For each scanned barcode, obtain:
Whether it is a Macro PDF417 via isMacroPDF417().
File ID via getMacroPDF417FileID().
Whether it is the last segment via isMacroPDF417LastSegment().
Segment index via getMacroPDF417SegmentIndex().
The barcode data via the Data property.
Summary
This tutorial has provided a comprehensive overview of integrating PDF 417 barcode reading capabilities into .NET applications using C# and VB.NET. Developers can leverage the BarcodeLib Barcode Reader SDK to scan and decode PDF 417 symbols from image files, extract detailed barcode properties, and handle Macro PDF417 structures. The component seamlessly integrates into ASP.NET web applications, Windows Forms desktop applications, and WPF based solutions, enabling robust barcode reading functionality across multiple .NET environments.