The following free Visual C# sample code only depicts how to scan PDF-417 barcode symbol from an image file on your local disk. You may also find related APIs for reading PDF-417 from a bitmap or stream of image source. In this C# coding example, PDF417 is defined as the target barcode type so that only this barcode type will be decoded from your image file.
public void ScanPDF417FromFile(string filename) { // Set PDF417 as the target barcode symbol and decode them all from an image file. BarcodeResult[] results = BarCodeScanner.Scan(filename, BarCodeType.PDF417); // APIs for reading PDF417 from Bitmap and Stream of image. // public static BarcodeResult[] Scan(Bitmap bitmap, BarCodeType barType); // public static BarcodeResult[] Scan(Stream stream, BarCodeType barType); foreach (BarcodeResult result in results) { Console.WriteLine(result.BarType.ToString() + "-" + result.Data); } }
If there's only one PDF-417 barcode on your image. You can use the following C# code to read PDF-417 barcode from image. This will help to improve barcode reader accuracy.
// Use this way to read barcode when there's only one barcode on image. Bitmap bmp = new Bitmap("YourImagePath"); BarcodeResult barcode = BarCodeScanner.ScanSingle(bmp); Console.WriteLine("barcode data:{0}.", barcode.Data);