Free Support Forum - aspose.com

Barcode Recognition from PDF

I have a scanned image on the PDF and most of the times my code works great. I recently found a pdf submission that was not processed by my code. However I see when I test it on the ASPOSE online barcode decoder page it does it correctly. Following is my code. Can you please advise for a fix?


foreach (XImage xImage in document.Pages[pageCount].Resources.Images)
{
using (MemoryStream imageStream = new MemoryStream())
{
xImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);
imageStream.Position = 0;

using (Aspose.BarCodeRecognition.BarCodeReader barcodeReader = new Aspose.BarCodeRecognition.BarCodeReader(imageStream, Aspose.BarCodeRecognition.BarCodeReadType.Code128))
{
barcodeReader.ImageBinarizationHints = RecognitionHints.ImageBinarization.MedianSmoothing;

while (barcodeReader.Read())
{
return barcodeReader.GetCodeText();
}

barcodeReader.Close();
}
}
}
Hi Paresh,

Thanks for your inquiry. I would like to update you that I'm able to recognize the barcode image using the provided source code. Please note that each new release contains many improvements, bug fixes and new features. So, we suggest you always use the latest version of Aspose products. Please visit the download pages 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

>>foreach (XImage xImage in document.Pages[pageCount].Resources.Images)

Please also make sure that you are passing a correct page number. In your case it should be one. I hope this will help you. Please let me know in case of further assistance and comments.