We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem recognizing printed PDF417 barcode

I am trying to read some pages printed with PDF417 barcodes. Those barcodes were generated with version 5.4 of Aspose.Barcode.
We could not find a way to read them with the latest version of Aspose.Barcode or with version 5.4.
The problem is that we do not have the original data. We only have the printed sheets.
In topic 28751 I have put some comments and the Aspose support people have kindly told me to open a new thread.
I attach an image that cannot be read (generated with version 5.4) and one that can (generated with 2.5). I also indicate the code used to read. Although in reality we used physical readers.
Thanks a lot
Bad.jpg (364.4 KB)
Good.jpg (366.0 KB)

var barCodeLicense = new Aspose.BarCode.License();

        // Good
        //var rutaOrigen = @"\xxxx\Imagenes\Good";
        //var rutaDestino = @"xxxxx\Imagenes\Good\Good-trans-barcode-20.10.zip";

        // Bad
        var rutaOrigen = @"xxxxxx\Imagenes\Bad";
        var rutaDestino = @"xxxx\Imagenes\Bad\Bad-trans-barcode-20.10.zip";

        using (var writer = File.OpenWrite(rutaDestino))
            var ficheroImagen = @"Bad.jpg";
            var files = new DirectoryInfo(rutaOrigen).GetFiles(ficheroImagen, SearchOption.TopDirectoryOnly);

            var encoding = Encoding.GetEncoding("ISO-8859-1");

            foreach (var strFile in files.OrderBy(s => s.Name))
                using (var reader = new BarCodeReader(strFile.FullName, DecodeType.MacroPdf417))
                    foreach (BarCodeResult result in reader.ReadBarCodes())
                        var data = encoding.GetBytes(result.CodeText);
                        writer.Write(data, 0, data.Length);

The code is also prepared to read the barcodes individually instead of in a single .jpg file

I tested both of these files with 5.4 and 20.11(developer) versions and both versions cannot read these barcodes. Also no side engine cannot read barcodes from these images. May be you have images with better resolution?

We only have the printed sheets.

Do you have printed sheets on paper or only scanned? If you have on paper, you can increase scanning resolution and try yet one time.

Hi @alexander.gavriluk
I attach image files with higher resolution.
I also attach the files obtained in each of the cases.
As you will see, the result in both cases is a .ZIP file. In one case it is a correct ZIP (it has a password but it is valid) and in another it is wrong.
The reading example is made with version 20.10

GoodV2.jpg (2.1 MB)
GoodV2-barcode-20.10.zip (2.0 KB)

BadV2.jpg (2.1 MB)
BadV2-barcode-20.10.zip (2.0 KB)

We only have the printed sheets.
The examples that we have attached we have currently obtained with the same program. That program generates a PDF. I have sent you the JPG files of the page that contains the barcodes.


With 20.11(develop version) everything is read well. May be here is problem with in 20.10 version (we fixed one rare bug with byte latch mode in pdf417 text mode stream), but I do not sure that this bug makes barcode unreadable.

string lFolder = @"d:\save\rec\";
BarCodeReader reader;

int lGoodPDFCounts = 0;
reader = new BarCodeReader(Path.Combine(lFolder, "GoodV2.jpg"), DecodeType.Pdf417, DecodeType.MacroPdf417);
lGoodPDFCounts = reader.ReadBarCodes().Length;

int lBadPDFCounts = 0;
reader = new BarCodeReader(Path.Combine(lFolder, "BadV2.jpg"), DecodeType.Pdf417, DecodeType.MacroPdf417);
lBadPDFCounts = reader.ReadBarCodes().Length;

string result = "Good barcodes read:" + lGoodPDFCounts.ToString() + " Bad barcodes read:" + lBadPDFCounts.ToString();

Ok, I understand you do not have barcode reading problem (it is read) you have problem with barcode decoding, because it is decoded incorrectly (generated in version 5.4)?

Was this question?

That’s exactly it.
With Aspose, the two cases are read but as a result one of them is not valid.
The starting data in both cases are the same.
When we read them with physical readers, the same thing happens.

We will analyze this information and share our feedback soon.

ISO-IEC-15438-2006.pdf (1.0 MB)

From version 4.6 up to 5.5 we have encoding bug in Pdf417 Byte Compaction mode. Problem was fixed in 5.6 version.

You can read section “ Compaction rules for encoding longer Byte Compaction character strings” from ISO/IEC 15438.

In normal mode we must encode byte stream by the group of 6 bytes (base 256) which encoded in 5 base 900 codewords. Last 5 or less bytes are encoded as is. In this way we have problems with group zero bytes encoding in compactification mode.

Just show where is the bug.

  1. we encode 6 bytes into big long

long val = bytes[0] * (2^40) + bytes[1] * (2^32) + bytes[2] * (2^24) + bytes[3] * (2^16) + bytes[4] * (2^8) + bytes[5];

  1. we create 5??? codewords

while(0 < val)
codewords.add(val % 900)
val /= 900
reverse codewords

Main problem in this code that it eats zeros from input byte stream.

And biggest problem that we cannot find how many zeros it ate and position where zeros were eaten. In this way I don’t see how to fix this bug. May be bruteforce on GPU could help.

Here is the application which can demonstrate the problem

Test54.zip (5.0 KB)

We have understood the problem and we do not see a possible solution in this way.

In some documents we have printed the information that also appears in the bar codes. We are going to hire a company to type them by hand. We see no other solution.
We sincerely appreciate the effort made to try to solve the problem.
Thanks a lot.