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

Free Support Forum - aspose.com

Problems reading QRCode image

Got a PDF that we are having trouble reading an image from. This image is of a QRCode, which seems to be processed from a PDF, but the PDF Extractor fails to detect any images when imported from a Fax source.

Are there any suggestions for improving the quality of the image so that it is detected as an image?

Hi Marvin,


Thanks for your inquiry. I am afraid while testing the scenario with latest version of Aspose.Pdf for .NET 9.2.0, image is being extracted fine from both files.

However, in scanned PDF document whole page is detected as a single image as it is added a single image by Fax source.


PdfExtractor pdfExtractor
= new PdfExtractor();<o:p></o:p>

pdfExtractor.BindPdf(myDir + "fax-140507-0908.pdf");

//extract all the images

pdfExtractor.ExtractImage();

//get all the extracted images

while (pdfExtractor.HasNextImage())

pdfExtractor.GetNextImage(myDir + DateTime.Now.Ticks.ToString() + ".jpg");


Please feel free to contact us for any further assistance.

Best Regards,

I’ve added two additional PDFs, these also seem to show up as a single image. However, the QRcode in these “fax-works” PDFs does process.

Hi Marvin,


Thanks for sharing additional information. Using Aspose.Pdf for .NET 9.2.0, we are able to identify and extract each page as an image from these files, as each image is being added as an image in these files. Please use latest version of Aspose.PDF, it will help you to read images. If issue persist then please share some more details about the issue, we will try to replicate it at our end and will provide you more information accordingly.

Best Regards,


Hi Marvin,


Thanks for sharing the resource files.

I have tested the scenario using Aspose.Pdf for .NET 9.2.0 in Visual Studio 2010 application with target platform as .NET Framework 4.0, running over Windows 7(x64) and as per my observations, the images are properly being extracted.

For your reference, I have also attached the images being extracted over my end. Can you please share which version of API you are using.

[C#]

PdfExtractor pdfExtractor = new PdfExtractor();<o:p></o:p>

pdfExtractor.BindPdf(myDir + "fax-works-2.pdf");

//extract all the images

pdfExtractor.ExtractImage();

//get all the extracted images

while (pdfExtractor.HasNextImage())

pdfExtractor.GetNextImage(myDir +“fax-works-2”+ DateTime.Now.Ticks.ToString()

  • “.jpg”);

Started with Aspose.Pdf for .NET 8.9.0, upgraded to Aspose.Pdf for .NET 9.2.1. Also using Aspose.BarCode for .NET 6.2.0.

The image appears to be extracted, but not processed.

Do While pdfExtractor.HasNextImage()

writeText(

"Getting next image....")

' save image to stream

Dim imageStream As New MemoryStream()

pdfExtractor.GetNextImage(imageStream)

imageStream.Position = 0

writeText(

"Recognizing barcode....")

' recognize the barcode from the image stream above

Dim barcodeReader As Aspose.BarCodeRecognition.BarCodeReader

Try

barcodeReader =

New Aspose.BarCodeRecognition.BarCodeReader(imageStream, BarCodeReadType.QR)

Do While barcodeReader.Read()

m_qrcode = barcodeReader.GetCodeText()

writeText(

"Codetext found: " & m_qrcode & ", Symbology: " & barcodeReader.GetReadType().ToString())

Loop

Catch ex As Exception

writeText(ex.ToString)

errorResponse(ex.ToString,

"Error recognizing barcode: " & m_sourceFileInfo.FullName.ToString)

End Try

' close the reader

barcodeReader.Close()

Loop

Do While pdfExtractor.HasNextImage()

writeText(

"Getting next image....")

' save image to stream

Dim imageStream As New MemoryStream()

pdfExtractor.GetNextImage(imageStream)

imageStream.Position = 0

writeText(

"Recognizing barcode....")

' recognize the barcode from the image stream above

Dim barcodeReader As Aspose.BarCodeRecognition.BarCodeReader

Try

barcodeReader =

New Aspose.BarCodeRecognition.BarCodeReader(imageStream, BarCodeReadType.QR)

Do While barcodeReader.Read()

m_qrcode = barcodeReader.GetCodeText()

writeText(

"Codetext found: " & m_qrcode & ", Symbology: " & barcodeReader.GetReadType().ToString())

Loop

Catch ex As Exception

writeText(ex.ToString)

errorResponse(ex.ToString,

"Error recognizing barcode: " & m_sourceFileInfo.FullName.ToString)

End Try

' close the reader

barcodeReader.Close()

Loop

Hi Marvin,


Thanks for your feedback. As you stated you are able to extract image but having issue in recognizing BarCode, so I am moving your request to Aspose.BarCode forum. There one of my colleagues will guide you appropriately.

We are sorry for the inconvenience caused.

Best Regards,

Hi Marvin,


Thank you for your inquiry. We’ve tested your four sample PDF files against the latest builds of Aspose.BarCode 6.2.0 and Aspose.Pdf 9.2.1. Each PDF file has a single QR code and it can be recognized as follows:

string[] files = Directory.GetFiles(@“C:\temp\test225”);<o:p></o:p>

foreach (string file in files)

{

int pageIndex = 0;

// bind the pdf

PdfConverter converter = new PdfConverter();

converter.BindPdf(file);

converter.RenderingOptions.BarcodeOptimization = true;

converter.DoConvert();

while (converter.HasNextImage())

{

pageIndex++;

MemoryStream pageStream = new MemoryStream();

converter.GetNextImage(pageStream, ImageFormat.Png);

using (BarCodeReader reader = new BarCodeReader(pageStream, BarCodeReadType.QR))

{

while (reader.Read())

{

Console.WriteLine(Path.GetFileName(file) + " Page#" + pageIndex + " Code Text: " + reader.GetCodeText() + " Type: " + reader.GetReadType());

}

}

}

}


Results:
fax-140507-0908.pdf Page#1 Code Text: DOCLOGIC|PQA|1018|Invoices|Invoices||||mmallette@farmersfurniture.com|2014-05-09 09:01 Type: QR
fax-works-2.pdf Page#1 Code Text: DOCLOGIC|PQA|1018|Invoices|Invoices|AP|DirectPay|Invoices|1@ff.com|2014-05-08 17:26 Type: QR
fax-works.pdf Page#1 Code Text: DOCLOGIC|PQA|CSR71|Invoices|Invoice|AP|Directpay|Invoices|bkilpatrick@farmersfurniture.com|2014-04-13 16:31 Type: QR
PQA_Dev_Simple.pdf Page#1 Code Text: DOCLOGIC|PQA|1018|Invoices|Invoices||||mmallette@farmersfurniture.com|2014-05-09 09:01 Type: QR

Please feel free to reply in case you have any further query or questions.