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

Free Support Forum - aspose.com

Problems reading QR-Code

Please have a look at the attached file “bad_code”. The barcode does can’t be read. The file “good_code” works fine - I cannot see any difference… Please help!

Thanks, Oliver



Code-Sample:

Using converter As New Aspose.Pdf.Facades.PdfConverter

converter.BindPdf(dateiname)

converter.RenderingOptions.BarcodeOptimization = True

converter.DoConvert()

While converter.HasNextImage

Dim imageStream As New MemoryStream

converter.GetNextImage(imageStream, Drawing.Imaging.ImageFormat.Png)



System.IO.File.WriteAllBytes(“c:\test.png”, imageStream.GetBuffer())



Using barcodeReader As New Aspose.BarCodeRecognition.BarCodeReader(imageStream, Aspose.BarCodeRecognition.BarCodeReadType.QR + BarCodeReadType.Code128 + Aspose.BarCodeRecognition.BarCodeReadType.DataMatrix)



Do While barcodeReader.Read()

Dim barcodesString(1) As String



barcodesString(0) = barcodeReader.GetCodeText()

Loop



’ close the reader

If String.IsNullOrEmpty(result) Then result = “keine Codes gefunden”



'Loop

barcodeReader.Close()

barcodeReader.Dispose()



End Using





End While

End Using

Hi Oliver,


Thank you for contacting support. We’ve tested your sample PDF document against the latest builds of Aspose.Pdf 9.3.0 and Aspose.BarCode 6.3.0. We can recognize QR code from “bad_code.pdf” file as follows:

int pageIndex = 0;<o:p></o:p>

// bind the pdf

PdfConverter converter = new PdfConverter();

converter.BindPdf(@"C:\test\bad_code.pdf");

converter.RenderingOptions.BarcodeOptimization = true;

converter.Resolution = new Aspose.Pdf.Devices.Resolution(300);

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("Page#" + pageIndex + " Code Text: " + reader.GetCodeText() + " Type: " + reader.GetReadType());

}

}

}


Result:
Page#1 Code Text: 7G801001020570 Type: QR

We hope, this helps.

Thank you! The following line did it:
converter.Resolution = new Aspose.Pdf.Devices.Resolution(300)

Best regards, Oliver

Hi Oliver,

Thank you for your reply. It is nice to hear from you that it solved the recognition problem. Please feel free to ask if you have any question regarding Aspose.BarCode product family, we will be happy to help you.