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

Free Support Forum - aspose.com

Error reading PDF417-barcode out of PDF

We encounter an error when trying to read some of the produced PDF417-barcodes. During a load test with random data we have about 1% of failure.
The barcode produced has the following structure:

  • 10 leading bytes with an identification number
  • the zipped data

I have attached an example:

  • “Testfile_167_I2_pers_1.pdf” is the PDF with the PDF417-barcode
  • “Testfile_167_I2_pers_1.zip” contains “Testfile_167_I2_pers_1.xml” with the initial data (…as I cannot upload XMLs…). It should be retrievable from the barcode.

Testfile_167_I2_pers_1.pdf (205.2 KB)
Testfile_167_I2_pers_1.zip (1.1 KB)


Thanks for the PDF document.

Which version of Aspose.BarCode for .NET you are using? I used newer versions with your PDF document and it works ok. I used the following sample code to retrieve the barcodes from PDF (I also used Aspose.PDF for .NET to render images from the PDF):
Sample code:

            string filename = "e:\\test2\\Testfile_167_I2_pers_1.pdf";
                Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(filename);
                Aspose.Pdf.Facades.PdfConverter pdfConverter = new Aspose.Pdf.Facades.PdfConverter(pdfDoc);
                pdfConverter.RenderingOptions.BarcodeOptimization = true;

                //set resolution to the page
                //300 dpi is standard resolution
                pdfConverter.Resolution = new Aspose.Pdf.Devices.Resolution(300);

                //set all pages to render into images
                pdfConverter.StartPage = 1;//starts from 1
                pdfConverter.EndPage = pdfConverter.Document.Pages.Count;

                //render selected pages to the images
                while (pdfConverter.HasNextImage())
                    //render current page to memory stream as png image
                    MemoryStream imageStream = new MemoryStream();
                    pdfConverter.GetNextImage(imageStream, ImageFormat.Png);
                    imageStream.Position = 0;

                    // Recognize the barcode from the image stream above
                    using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(imageStream, Aspose.BarCode.BarCodeRecognition.DecodeType.AllSupportedTypes))

                        //Normal quality mode which sets SVM detector to more sensitive mode
                        reader.QualitySettings = Aspose.BarCode.BarCodeRecognition.QualitySettings.MaxBarCodes;

                        foreach (Aspose.BarCode.BarCodeRecognition.BarCodeResult barcodeResult in reader.ReadBarCodes())
                            Console.WriteLine("Codetext found: " + barcodeResult.CodeType + ", Symbology: " + barcodeResult.CodeText);


            catch (Exception ee)
                Console.WriteLine("Error Message: " + ee.Message);
                Console.WriteLine("Error Stack Trace: " + ee.StackTrace);



Codetext found: Matrix2of5, Symbology: 07813
Codetext found: Matrix2of5, Symbology: 8689866
Codetext found: Matrix2of5, Symbology: 26587831
Codetext found: Codabar, Symbology: 42-
Codetext found: Matrix2of5, Symbology: 71860472
Codetext found: Matrix2of5, Symbology: 6721
Codetext found: Matrix2of5, Symbology: 39270888
Codetext found: Codabar, Symbology: 20200-16
Codetext found: QR, Symbology: 
Codetext found: Matrix2of5, Symbology: 707197
Codetext found: Matrix2of5, Symbology: 2830
Codetext found: Pdf417, Symbology: ?[znd: Matrix2of5, Symbology: 8941
Codetext found: Matrix2of5, Symbology: 838472
Codetext found: Matrix2of5, Symbology: 39270888
Codetext found: Matrix2of5, Symbology: 542506
Codetext found: Codabar, Symbology: 2020

Could you elaborate where is the issue? Also, could you share your sample code and current output details. Moreover, share your expected barcode details. We will check your issue soon.