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

Free Support Forum - aspose.com

Reader.Read() returns false

Using Aspose.BarcodeRecognition v3.0 (yes, old…)


When I have a nice pristine PDF, the reader works great. But when the document is passed through a document scanner, saved to a pdf, then read using the Barcode Recognition libraries, it doesn’t read the barcode.

The newer versions allow you to set hints, etc. How can I do that in v3.0? I’ve attached a .BMP saved from the scan (after a .GetNextImage()), the original PDF (pristine), and the scanned PDF.

Here is my code:
public static string[] ReadBarcodePdf(string filename)
{
GrabLicense(true);

string[] codes = new string[1];

// bind the pdf document
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(filename);
// set page range for image extraction
pdfExtractor.StartPage = 1;
pdfExtractor.EndPage = 1;
// extract the images
pdfExtractor.ExtractImage();
// save images to stream in a loop
while (pdfExtractor.HasNextImage())
{
// save the image in memory stream
using (MemoryStream imgStream = new MemoryStream())
{
pdfExtractor.GetNextImage(imgStream);
imgStream.Position = 0;

// recognize the barcode from the image stream above
using (BarCodeReader reader = new BarCodeReader(new Bitmap(imgStream), BarCodeReadType.Code39Standard))
{

while (reader.Read())
{
if (!string.IsNullOrEmpty(codes[0]))
{
Array.Resize(ref codes, codes.Length + 1);
}
codes[codes.Length - 1] = reader.GetCodeText().Replace(BarCodeDelimiterEscape, BarCodeDelimiter);
}
}
}
}
return codes;
}



Hi,


Thank you for using Aspose products.

I am afraid, you need to upgrade to some newer version of Aspose.BarCode for .Net if you want to use the advanced features like Recognition Hints.

Please feel free to contact us in case you have further comments or questions.