C# Barcode Reader How-Tos
PM > Install-Package BarcodeLib.BarcodeReader


In this article
Home > .NET Barcode Reader > .NET Barcode Reading Guide > .NET PDF-417 Barcode Reader for C#, VB.NET Applications

.NET PDF-417 Barcode Reader for C#, VB.NET Applications

Scan & Read PDF-417 barcodes in C#.NET, VB.NET, ASP.NET projects
  • Easily read & scan PDF-417 barcodes in .NET applications
  • Reading PDF-417 barcode images in JPEG, GIF, PNG, BMP, TIFF formats
  • 100% written in Visual C#.net, compatible with .NET 2.0 or greater versions
  • Provide complete sample C#.net, VB.net demo codes for C# & VB.NET developers
  • Mature PDF417 .NET Barcode Reader Component SDK since 2003
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
  1. 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.
     string[] results = BarcodeReader.read("c:/pdf417-barcode.gif", BarcodeReader.PDF417);
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() As String = 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).
  1. 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.

  2. 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);

setting.setAreas(areas);

string[] results = BarcodeReader.read("c:/pdf417-barcode.gif", BarcodeReader.PDF417, setting);
The following VB.NET code explains how to scan top 20% of the image and bottom 20% of the image.
     Dim setting As OptimizeSetting = New OptimizeSetting()

setting.setMaxOneBarcodePerPage(True)

Dim top20 As ScanArea = New ScanArea(New Drawing.PointF(0.0F, 0.0F), New Drawing.PointF(100.0F, 20.0F))

Dim bottom20 As ScanArea = New ScanArea(New Drawing.PointF(0.0F, 80.0F), New Drawing.PointF(100.0F, 100.0F))

Dim areas As List(Of ScanArea) = New List(Of ScanArea)
areas.Add(top20)
areas.Add(bottom20)

setting.setAreas(areas)

Dim datas() As String = BarcodeReader.read("c:/pdf417-barcode.gif", BarcodeReader.PDF417, setting)


How to Extract Scanned PDF417 Barcode Property Information in C#

After obtaining the scanned barcode details in a BarcodeDetail object, use the GetBarcodeProps() method to retrieve PDF 417 specific properties:
  • ColumnCount: Number of data columns in the PDF417 symbol (excluding start/stop pattern and left/right row indicators).
  • RowCount: Number of rows in the PDF417 symbol.
  • DataMode: PDF417 data mode used during encoding; PDF417DataMode.Mix indicates multiple modes.
  • ECL: Error correction level used.
  • IsMacro: Indicates whether the symbol is a Macro PDF417.
  • If Macro PDF417:
    • MacroSegmentIndex: Segment index (starting from 0).
    • MacroFileID: File identification as an array of codewords (each in range 0 - 899).
    • IsMacroLastSegment: Indicates if this is the last segment.
    • MacroOptFieldEnable: Indicates presence of optional fields.
    • Optional fields: MacroFileName, MacroSegmentCount, MacroTimeStamp, MacroSender, MacroAddressee, MacroFileSize, MacroChecksum.


Scan and Read Macro PDF417 Barcodes Using C#

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.
  1. Use BarcodeScanner.ScanInDetails() to retrieve all PDF417 barcode information from an image.
  2. 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.

.NET Barcode Reader & Scanner Supporting Barcode Types/Symbologies
Read .NET 1D Barcodes:
Read .NET 2D Barcodes:
All Decodable Linear Barcodes: Codabar, Code 39, Code 128, Interleaved 2 of 5, EAN 8, EAN 13, UPC-A, UPC-E.

All Decodable Matrix Barcodes: Data Matrix, PDF-417, QR-Code.