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

Free Support Forum - aspose.com

Aspose.barCode in not reading the file in C#.net Core

Hi All,
CRN_4075002461_20210310_085032.pdf (175.8 KB)

We are using the following attached file, its a pdf first we are converting it to PNG file with the Help of Aspose.Pdf.pfdConverter with below mention height and width
then we are trying to read that png file to decode the text from QRCode attached in that PNG file , Can somebody help me what i did wrong here.
// Conversion
string asposeLicense = Configuration.ASPOSE_LICENSE_PATH;
_logger.LogWarning(“asposeLicense =” + asposeLicense);
Aspose.Pdf.License pdflicense = new Aspose.Pdf.License();
pdflicense.SetLicense(asposeLicense);
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(createdfilePath);
int i = 1;
foreach (var page in pdfDocument.Pages)
{
string imagename = Guid.NewGuid().ToString();
string FilePath = createdImagePath + “\” + imagename + i + “.png”;
_logger.LogWarning(“FilePath =” + FilePath);
//
// Create file stream for output image
using (FileStream imageStream = new FileStream(FilePath, FileMode.Create))
{
// Create Resolution object
Resolution resolution = new Resolution(3000);

                    // Create Png device with specified attributes
                    // Width, Height, Resolution
                    //PngDevice PngDevice = new PngDevice(1653, 2339, resolution);
                    PngDevice PngDevice = new PngDevice(1653, 2339);
                    PngDevice.Process(page, imageStream);

                    // Close stream
                    imageStream.Close();
                    ImagesInPdf.Add(FilePath);
                    _logger.LogWarning("ImagesInPdf =" + ImagesInPdf);

                }
            }

//Reading
//Setting Aspose
string asposeLicense = Configuration.ASPOSE_LICENSE_PATH;
Aspose.BarCode.License pdflicense = new Aspose.BarCode.License();
pdflicense.SetLicense(asposeLicense);
_logger.LogWarning("asposeLicense = "+ asposeLicense);
try
{
foreach (var imagepath in Imagespaths)
{
_logger.LogWarning("imagepath = " + imagepath);
using (BarCodeReader reader = new BarCodeReader(imagepath))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
{
//Console.WriteLine(“Type: " + result.CodeType + " QRCODE FOUND”);
//Console.WriteLine("CodeText: " + result.CodeText);
string DecryptedString = result.CodeText;
_logger.LogWarning("DecryptedString = " + DecryptedString);
string[] findtheQrCodeisEinvoice = DecryptedString.Split(’.’).ToArray();

                            if (findtheQrCodeisEinvoice.Length == 3)
                            {
                                ValidQrCodeList.Add(DecryptedString);
                            }
                            else
                            {
                                NotValidQrCodeList.Add(DecryptedString);
                            }
                        }
                    }

                    

               // }
            }
           
        }

Deployed application in Linux server, its a .net core 3.1 application

@rahulcodepractise,
I have tried this scenario using the latest versions of Aspose.BarCode and Aspose.Pdf both. It is observed that the intermediate PNG file contains black box instead of the barcode image. Could you please share the intermediate PNG image file saved by your application for our reference? Here is the image that is generated at our end.

TestPDF.zip (1.4 KB)
Use pdf page rendering instead of image extracting

TestPDF.ExtractRenderedPDFPagesToFolder(@"d:\save\rec\pdf\CRN_4075002461_20210310_085032.pdf", -1, @"d:\save\rec\pdf\img\");