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

Free Support Forum - aspose.com

Barcode recognition does not find barcodes (on PDF)

Hi,
I need to read barcodes from a pdf document.
I read from your documentation that I must extract images from the pdf document and process them with the BarCodeReader object.

But, unfortunately, this way does’nt work for some barcodes.
Please check the attached document.

Why the barcode was not found?

My test code is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aspose.Pdf.Kit;
using System.IO;
using Aspose.BarCodeRecognition;


namespace ConsoleApplication1 {
class Program {

const string ASPOSE_LIC_PATH = “Aspose.Total.lic”;

static void Main(string[] args) {
try {

// set the license for Aspose.BarCode for .NET and Aspose.Pdf.Kit for .NET components
Aspose.BarCodeRecognition.License licenceBarCodeRecognition = new Aspose.BarCodeRecognition.License();
licenceBarCodeRecognition.SetLicense(ASPOSE_LIC_PATH);
Aspose.Pdf.Kit.License licensePdfKit = new Aspose.Pdf.Kit.License();
licensePdfKit.SetLicense(ASPOSE_LIC_PATH);

// bind the pdf document
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(@“FATTP00000000005.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);
imageStream.Position = 0;
Console.WriteLine(“Recognizing barcode…”);

// recognize the barcode from the image stream above
BarCodeReader barcodeReader = new BarCodeReader(imageStream, BarCodeReadType.Code128);
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);
}

Console.WriteLine(“Press Return to terminate”);
Console.ReadLine();
}

}

}

Hi, I’ve noticed that with an older version of the barcode libraries the barcode was readed!!

The old version I’ve tried is the 4.1.0.0 both for Aspose.BarCodeRecognition.dll and Aspose.BarCode.dll.

My current version is the 4.5.0.0 (for both libraries).

Is tihs a new bug introdiced with latest versions?
Can I use old libraries without any risk?


Hi Alessandro,


Thank you for your inquiry.

We have found some recognition problems in the latest release (v4.5.0). We have concluded that the presence of skewness in the image sometimes make it difficult for the BarCodeReader to correctly detect and read the barcode label. We are currently working on an algorithm that will auto de-skew the image before feeding it to BarCodeReader for scanning purposes. This fix is scheduled for release in 6th~7th week of 2012.

Until this issue is resolved, you can use the previous version without any known risks.

We apologise for your inconvenience.

Hi,


I have the same problem. I am using another tool to extract the page image from PDF. I was using Aspose.BarCode v 4.1 and was experiencing recognition failures on scanned documents. I despeckle and deskew the document myself and still have errors. I’ve upgraded to v4.5 in hopes of solving this problem but it persists.

I can provide a sample tiff but I cannot post it in the forum.

Thanks,
Jason

Hi Jason,


Thank you for your inquiry.

Will you be kind enough to start a new thread and attach your problematic sample file with it? So we may analyse the problem and if required associate your post with the appropriate ticket from our bug tracking system.

Regards,

Hi,
I’ve found some others problems with pdf documents.
Please see the attached PDF document: I’ cannot read the EAN13 barcode inside.

This is my code (using Aspose.BarCode 4.1.0.0 and Aspose.BarCodeRecognition 4.1.0.0):

static void testReadFromPDF () {
try {

// set the license for Aspose.BarCode for .NET and Aspose.Pdf.Kit for .NET components
Aspose.BarCodeRecognition.License licenceBarCodeRecognition = new Aspose.BarCodeRecognition.License();
licenceBarCodeRecognition.SetLicense(ASPOSE_LIC_PATH);
Aspose.Pdf.Kit.License licensePdfKit = new Aspose.Pdf.Kit.License();
licensePdfKit.SetLicense(ASPOSE_LIC_PATH);

// bind the pdf document
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(@“document1.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);
imageStream.Position = 0;
Console.WriteLine(“Recognizing barcode…”);

// recognize the barcode from the image stream above
BarCodeReader barcodeReader = new BarCodeReader(imageStream, BarCodeReadType.EAN128);
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);
}

Console.WriteLine(“Press Return to terminate”);
Console.ReadLine();
}

Any help?

Hi,


Thank you for providing your sample.

Please find attachment for the latest assemblies of Aspose.BarCode for .NET v4.5.0.1. I have tested these assemblies can correctly recognize the barcode from your provided document.

Please give a try at your end and feed us back with your results.

Hi, thank you for your support.
I’ve tested the new DLLs (4.5.0.1) and they are ok whith my document1.pdf.
But now I’m testing your DLLs over various document to find other issues.
Now I’ve problems with the new attached document.

The code is the same as previous (only replace BarCodeReadType.EAN13 with BarCodeReadType.Code128), and the problem is that the found barcode is incorrect because it has an initial “f” character:

Codetext found: fD00000001863, Symbology: Code128

Any suggestions?

I’m a little worried about your libraries… because my application is based on your libraries for writing and reading barcodes and then it is very important for me that they work correctly!

Hi,


Please accept my apologies for this inconvenience.

I am able to observe your said issue. So I have logged it in our bug tracking system under ticket Id BARCODENET-33143. Can you please share your source code to generate these barcodes?

Thanks in advance

I’ve generated the barcode with the Aspose.BarCode.BarCodeBuilder but then I’ve printed the document using PDFCreator.


Hi,


Thank you for your response.

It would be of great help if you can provide a sample application/code to generate the barcodes. Asking so cause I tried producing similar barcodes on my end and they get scanned without any problem. I used the same assemblies as shared earlier in this thread for generation and recognition purposes.

Hi, I’m not able to give you my code to generate the file, as I said,
the file was generated by printing the image on PDFCreator.

But I
think that the problem is on the recognition library, because I can
easily read the barcode on the file by other apps (for example a simple
barcode reader on my iphone, reading through the monitor!).

I’ve created a new private post with an attached file, that is confidential.
The attached file has a barcode that I cannot read with aspose
libraries (both with 4.1.0.0 and 4.5.0.1 versions). This file is
generated by one of our customers, with its ERP.
Even in this case I can read the barcode with my iphone simple app!
The link to the post is:

https://forum.aspose.com/t/another-file-with-barcode-that-cannot-be-read/16327

Thank you for your support.

Hi,


Thank you for your response.

Its Ok. The ticket (BARCODENET-33143) logged earlier in reference to the issue of an extra character at the start of scanned CodeText, has been marked “Fixed” by the development team. Now, I also believe the problem was in recognition process. I have requested for the RCA on this ticket and as soon as I receive any updates, I will let you know here.

Regarding your other post, I will reply you there after analysing your shared document.

The issues you have found earlier (filed as BARCODENET-33143) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.