Pdf417 Barcode Decoder

2 May 2019CPOL
The PDF417 barcode decoder class library allows you to extract PDF417 barcode information from image files. The library is written in C# for the .NET framework. The two demo projects allows you to explore the library and read PDF417 barcodes.

The PDF417 barcode decoder class library allows you to extract PDF417 barcode information from image files. The library is written in C# for the.NET framework. The two demo projects allows you to explore the library and read PDF417 barcodes.

Introduction

The PDF417 barcode decoder class library allows you to extract PDF417 barcode information from image files. The library is written in C# for the .NET framework. It is the second article published by this author on encoding and decoding of PDF417 barcodes. The first article is PDF417 Barcode Encoder .NET Class Library and Demo App. You can use the encoder article to generate barcode image files to test the decoder. The decoder class reads an image file containing PDF417 single barcode or multiple barcodes and returns an array of results. The primary result is a byte array or multiple byte arrays. Methods are available to translate byte array to a text string based the ISO-8859 standard. Two demo/test projects are included to test the library. The Pdf417DecoderDemo reads barcode image files. The Pdf417VideoDecoder captures web camera pictures and decodes the PDF417 barcodes.

PDF417 is a two-dimensional barcode. The barcode documentation and specification can be found in the following websites. Wikipedia provides a good overview of the PDF417. Click here to access the page. The PDF417 standard can be purchased from the ISO organization at this website. An early version of the specifications is freely available to be downloaded at this website. I strongly recommend that you download this document if you want to fully understand the decoding process.

The software attached to this article is a PDF417 decoder library, and two demo/test programs. The software is written in C# for the .NET framework. This article explains the decoding process. How to integrate the decoder to your application. And how to use the demo/test programs.

PDF417 Barcode Decoding Process

An example of PDF417 barcode taken from the Wikipedia article referenced above is given below:

  • Read the image file and convert it into Boolean array of black and white pixels.
  • Scan the image horizontally line by line, left to right, and locate the start and stop patterns. If no start and stop signatures are found, scan the image right to left. The maximum tilt angle of the barcode relative to the image is about plus minus 30 degrees from the horizontal axis.
  • If the image contains more than one PDF417 barcode, the following steps will run for each barcode.
  • Scan the left row indicator column and the right row indicator column. The indicator columns codewords contain the number of data rows and columns, and the length of the error correction codewords.
  • Locates the top left indicator codeword, bottom left indicator codeword, top right indicator codeword and the bottom right indicator codeword.
  • Using the information from the previous two step, calculate the coefficients of projective mapping matrix. These coefficients will translate data row and column coordinates to pixels’ image coordinates. See Fundamentals of Texture Mapping and Image Warping (Page 19).
  • Extract the data codewords.
  • Run the error detection and correction algorithm.
  • Decompress the codewords into bytes.
  • If the result is successful save the result.
  • Repeat the last few steps for each barcode found.
  • Return to the calling application the number of successful barcodes detected.
  • If the returned barcode count is zero, no barcodes were detected, or none were successfully decoded. If the count is greater than zero, the results are returned in an array of barcode information, or in an array of arrays of binary bytes.
  • The returned binary data (bytes array) can be converted to text string using the global label identifier CharacterSet value.

PDF471 Decoder Project Source Code

The attached Visual Studio solution source Pdf417DecoderLibrary file includes three projects:

  • Pdf417DecoderLibrary: The decoder library consists of all the classes required to decode an image. The main class is Pdf417Decoder.
  • Pdf417DecoderDemo: The demo application allows you to test the decoder. It will decode an image file.
  • Pdf417VideoDecoder: The video decoder is a demo application that will use the first found web camera in your system to capture a PDF417 barcode image and decode it.

Integrating the PDF417 Decoder Library to Your Application

Include the Pdf417DecoderLibrary.dll class library with your project. Install the attached Pdf417EncoderLibrary.dll file in your development area. Start Visual Studio. Open your application. Go to the Solution Explorer. Right click on References and select Add Reference. Select the Browse tab and navigate your file system to the location of the installed Pdf417EncoderLibrary.dll. When your application is published, the file Pdf417EncoderLibrary.dll must be included and installed in the same folder as your executable (.exe) file.

The namespace of the library is Pdf417DercodeLibrary. Add a using statement to all your source files referring to this library.

Calling the PDF417 Decoder from Your Application

  • Create a Pdf417Decoder object. This object can be serially reused.
  • Call the Decode method with an image file name.
  • The return value is the number of detected barcodes count.
  • If the return value is zero, no barcode was found or was decoded successfully.
  • If the return value is greater than zero, iterate through all found barcodes.
  • There are three ways to access the results:
    • Read array of barcode binary data.
    • Read array of full barcode information.
    • Call BinaryDataToString method to return a text string for one binary data result.

Below, you will find an example of code sequence to be added to your application to read PDF417 barcodes.

Full Barcode Information Result Class

The main result of decoding is the binary byte array. The library provides you with additional information about the barcode. The BarcodeInfo class is described below:

Binary Data to Text String

It is important to note that the barcode encodes an array of bytes not array of characters (text string). The decoding process recover the bytes from the barcode image. To encode text string, one must convert characters to bytes. The decoder must convert bytes to characters. As long as these two conversions are symmetrical encoding and decoding text will work. These conversions are not part of the PDF417 specification. The only support given to this process is the global label identifier character set. The encoder set this value as a function of ISO-8856-part. The decoder can read it and process the byte array properly.

In order for the two decoding methods given below to work, the encoder must encode text as follows:

Pdf417 Barcode Decoder

The Pdf417Decoder class has two methods to convert binary data to text string.

A static method:

A method that convert the byte array to text string based on the global label ID character set:

Pdf417 Barcode Font

PDF417 Decoder Demo/Test Program

The Pdf417DecoderDemo project was designed to demonstrate and test all the features of the PDF417 Decoder Library. Click on the PDF417Image button. Select an image containing a PSD417 barcode. And watch the results. If you are running the program within the Visual Studio environment in debug mode, you can view the trace file Pdf417DecoderTrace.txt in a text editor. Scroll to the end of the file for the most recent results.

Another example of decoding an image with two barcodes.

PDF417 Video Decoder Demo/Test Program

The PDF417 Video Decoder Pdf417VideoDecoder is a test/demo application that will use the first found web camera in your system. A demo program combines PDF417 decoder and video camera image capture. The video camera software is based on the Direct Show Library.

This demo program is using some of the source modules of Camera .NET Project published at CodeProject.com and at Github project is based on DirectShowLibDirectShowLib.. Please note the DirectShowLib in this project is a modified subset of the original source modules.

Please note, I have only tested this application on my own video camera. My camera is Logitech HD Webcam C615. I am using frame size of 640 by 480 pixels.

The program sets the camera software to display the video stream in a preview area on the screen. The scanning is 5 frames per seconds. Each frame is captured and tested for a PDF417 barcode. Once a barcode is found, the result is displayed at the Decoded data text box. Decoding stops until the reset button is pressed. If the decoded data is a URI, the Go To URI button is enabled, and you can display this URI on your default web browser.

For video decoding to be successful, each barcode module must be represented by a few camera pixels. For example, 4 by 12 or more pixels. The barcode must be reasonably sharp, flat and parallel to the camera. The picture below illustrates the power of the software to transform the image to a square with the finder symbols at their correct positions.

History

  • 2019/05/01: Version 1.0 - Original version
Active4 months ago

I am looking for a .NET library that is able to decode data from a PDF-417 barcode that is embedded either in an image file or PDF. At this point, I have only been able to find a Java version and a C version.

Ideally, this library would be both open-source and free of charge, but I doubt such a decoder exists.

I am open to trying out demos of existing products that you may have had experience with - which leads me to the question - have you had any experience reading PDF-417 barcodes embedded in images or PDFs using .NET, and which of the available products would you recommend to do so?

John RaschJohn Rasch
51.2k18 gold badges97 silver badges134 bronze badges

Pdf417 Barcode Encoder Drvlic Xml Online

6 Answers

We use components (not free) from IDAutomation for PDF417. They are very good. We use them for encoding, as opposed to reading and decoding.

Haven't used this component of theirs, but have a look it is C#, and you can obtain the source code, but again, not free.

MikeWMikeW

The ClearImage Barcode Recognition SDK for .NET is probably the easiest way to decode PDF 417 and many other barcodes. I use it in many projects... although it is not free

Ronnie BarnardRonnie Barnard

try this

This is a zxing c# port

Ant
4,1751 gold badge25 silver badges42 bronze badges
mengmeng

Aspose has a PDF417 encoder/decoder for both .NET and Java, but it is not open source: http://www.aspose.com/categories/.net-components/aspose.barcode-for-.net/default.aspx

Pdf417 decoder software
user175832
cuteCATcuteCAT
1,3533 gold badges17 silver badges26 bronze badges

I've just successfully integrated the ZXing .Net port from java. It's not as powerful as other paid SDK's - for instance it couldn't detect barcodes in a rotated image. However, it's free and might work for you if you're on a budget. Generally you'll find the paid SDKs cost $400 and up. It has over a million downloads on Nuget, if that means anything.

SavageSavage

Not the answer you're looking for? Browse other questions tagged c#.netbarcodedecode or ask your own question.

Comments are closed.