Free Support Forum - aspose.com

Bulk scan documents separated by QR codes

We Aspose to convert the bulk scanned files into a single pdf document. We use Aspose barcode reader to read the information contained in each QR code.

Each page of the file is created by Aspose as an image.

Sometimes a QR code is not found by the barcode reader, maybe it is too faint, too small, or perhaps it was resized prior to insertion into the document.

Is there ANY way we can identify that a barcode is there but just couldn't be read?

Thanks -

Tim

Hi Tim,


Thanks for your inquiry. Could you please share your sample code and source document here? So we will look into the issue and provide you more information accordingly.

Sorry for the inconvenience faced.

Best Regards,

...The following is an excerpt of the code. If all the barcodes are readable, then the original pdf file is successfully split into separate pdf documents. If a barcode inside the document is not recognized, then it will just be included with the document that started with a valid barcode.

***********************************************************************

////bind the pdf document
Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
pdfExtractor.BindPdf(fs);

for (i = 1; i<=docNumberOfPages; i++)
{
Console.Write("\nPage " + i.ToString());
//get every valid barcode.

barcodeText = GetBarcodeText(pdfExtractor, i);
if (barcodeText != string.Empty)
{
//validate
validbarcode = ValidateBarcode(barcodeText);
if (validbarcode)
{
if (prevDocBarCodeText == "")
{
prevDocBarCodeText = barcodeText;
docFirstPage = i;
validbarcode = true;
}
else //this is the first page of the next document
{
docLastPage = i - 1;

//CreateNewDoc creates the new pdf document and returns the filename created
filesCreated = filesCreated + "\n " + CreateNewDoc(fs, docFirstPage, docLastPage, FilePath, prevDocBarCodeText, DocumentLibraryPath, upload);
prevDocBarCodeText = barcodeText;
docFirstPage = i;

//reset upload flag so rest of documents with valid barcodes will upload//reset flag so rest of documents with valid barcodes will upload
upload = true;
}
if (i == docNumberOfPages)
{
//this is also the last page
docLastPage = i;
Console.WriteLine(" -- Last Page!\n\n");
filesCreated = CreateNewDoc(fs, docFirstPage, docLastPage, FilePath, prevDocBarCodeText, DocumentLibraryPath, upload);
}
}
}

**************************Remaining code to handle what page I'm on and what I want to do.

Hi Tim,


Thanks for sharing code sample. Can you please also share a sample problematic document here? So we will test it and share the information accordingly.

Sorry for the inconvenience faced.

Best Regards,

Rather than the whole document I have attached the failing barcode -

Hi Tim,


I’m representative of Aspose.BarCode product family.

Thanks for sharing the sample document. First off, please try to use the latest version of Aspose.BarCode for .NET 5.4.0 because each new release contains many improvements, bug fixes and new features. So, we suggest you always use the latest versions of Aspose products. You can download it from here:
http://www.aspose.com/community/files/51/.net-components/aspose.barcode-for-.net/default.aspx
http://www.aspose.com/community/files/51/.net-components/aspose.pdf-for-.net/default.aspx

I tested your sample Pdf file against the latest version of Aspose.BarCode for .NET 5.4.0 and Aspose.Pdf for .NET 7.7.0 components. I would like to update you that I am able to recognize the barcode. Please follow up the source code below:

try<o:p></o:p>

{

int i = 0;

// bind the pdf document

PdfExtractor pdfExtractor = new PdfExtractor();

pdfExtractor.BindPdf(@"C:\AB\test44\20130219130306948.pdf");

// set page range for image extraction

pdfExtractor.StartPage = 1;

pdfExtractor.EndPage = 1;

// extract the images

Console.WriteLine("Extracting images.....");

pdfExtractor.ExtractImage();

// save images to stream in a loop

while (pdfExtractor.HasNextImage())

{

Console.WriteLine("Getting next image....");

// save image to stream

MemoryStream imageStream = new MemoryStream();

pdfExtractor.GetNextImage(imageStream);

Console.WriteLine("Recognizing barcode....");

// recognize the barcode from the image stream above

BarCodeReader barcodeReader = new BarCodeReader(imageStream, BarCodeReadType.QR);

while (barcodeReader.Read())

{

Console.WriteLine("Codetext found: " + barcodeReader.GetCodeText() + ", Symbology: " + barcodeReader.GetReadType().ToString());

}

// close the reader

barcodeReader.Close();

}

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}


I hope this will help you. Please let us know in case of further assistance and comments.


Hi Tim,


In addition, I’m not sure about what the GetBarCodeText method is returning in your source code. In case the barcode is not recognized and GetBarCodeText method is returning an empty string then you are creating a PDF document within the condition like:

if (barcodeText != string.Empty)<o:p></o:p>


In case of ambiguity, please share the entire source code. We will take a closer look and guide you accordingly.

Hi Tim,


Thanks for sharing the resource file.

As per my understanding, you are extracting the image from PDF file using PdfExtractor and then using Barcode reader to read the barcode. Whereas 20130219130306948.pdf is the file which is causing issue when image is extracted from this file and barcode is not properly understanding/recognizing the QR code.

I have tested the scenario where I have used Aspose.Pdf for .NET 7.7.0 to extract image from attached PDF file and as per my observations, the resultant image is fine and barcode is properly appearing. For your reference, I have also attached the resultant image file. We are sorry for this inconvenience.

In case I have not properly understood your requirement, please share some further details.

I was able to read the barcode with these latest dlls.

Thanks for the help!

Tim

So I am able to get the barcode with the latest dlls - thanks for your help!

Tim

Hi Tim,


Thank you for these details. It is nice to hear from you that you are able to recognize barcode images. Please feel free to ask if you have any question about Aspose products, we will be happy to help you.