Barcode not getting recognized by reader.ReadBarCodes() for the attached file

I am facing issues while recognizing barcodes for the latest versions of Aspose.barcode and Aspose.pdf for web applications.

Aspose.Barcode : 22.5.0.0 or 22.6.0.0
Aspose.PDF: 22.6.0.0

Code Snippet:

using (Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(@“C:/MyProjects/BarCodeTest/TestFiles/UnRecognized_YBarcode.pdf”))
{
Aspose.BarCode.License license = new Aspose.BarCode.License();
license.SetLicense(“Aspose.Total.lic”);
Aspose.Pdf.License license1 = new Aspose.Pdf.License();
license1.SetLicense(“Aspose.Total.lic”);

            Dictionary<int, string> dictBarCode = new System.Collections.Generic.Dictionary<int, string>();
            Aspose.Pdf.Devices.PngDevice pngDevice = new Aspose.Pdf.Devices.PngDevice(new Aspose.Pdf.Devices.Resolution(300));

            //proceed all pdf pages, pages start from 1
            for (int i = 1; i <= pdfDoc.Pages.Count; ++i)
            {
                //render pdf page to the stream
                using (MemoryStream ms = new MemoryStream())
                {
                    pngDevice.Process(pdfDoc.Pages[i], ms);
                    ms.Position = 0;

                    //recognize barcode
                    BarCodeReader reader = new BarCodeReader(ms, DecodeType.Code128);

                    foreach (BarCodeResult result in reader.ReadBarCodes())
                    {
                        try
                        {
                            string code = result.CodeTypeName;
                            string codeText = result.CodeText;
                            dictBarCode.Add(i, codeText);
                        }
                        catch { }

                    }
                }
            }

Please check attached files of recognized and unrecognized barcode files. Unable to understand the issue with UnRecognized_YBarcode.pdf file and want to fix it earlier.

Please find attachments and let me know how can we fix this issue.
Recognized_CBarcode.pdf (731.1 KB)
UnRecognized_YBarcode.pdf (41.7 KB)

Thanks!

Just have checked:

Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(@"d:\save\rec\UnRecognized_YBarcode.pdf");
Dictionary<int, string> dictBarCode = new System.Collections.Generic.Dictionary<int, string>();
Aspose.Pdf.Devices.PngDevice pngDevice = new Aspose.Pdf.Devices.PngDevice(new Aspose.Pdf.Devices.Resolution(300));

//proceed all pdf pages, pages start from 1
for (int i = 1; i <= pdfDoc.Pages.Count; ++i)
{
    //render pdf page to the stream
    using (MemoryStream ms = new MemoryStream())
    {
        pngDevice.Process(pdfDoc.Pages[i], ms);
        ms.Position = 0;

        //recognize barcode
        BarCodeReader reader = new BarCodeReader(ms, DecodeType.Code128);

        foreach (BarCodeResult result in reader.ReadBarCodes())
        {
            try
            {
                string code = result.CodeTypeName;
                string codeText = result.CodeText;
                dictBarCode.Add(i, codeText);
            }
            catch { }

        }
    }
}

.Net Framework 4.8
Result:
“YSI~1~psres3~t0009782 ~Documents~Barcode 128 Test20220526.pdf”

I think the problem could be in place where license is set. You should at first set the license, then manipulate with files or images.

You can use singleton for lazy license initialization