The following code cannot read barcode from the attached PDF file. I have tried my best but it is not working. Please help. I am using the v4.0.30319 version of Aspose.BarCode.dll and v4.0.30319 of Aspose.Pdf.Kit.dll.
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Aspose.BarCodeRecognition;
using Aspose.Pdf;
using Aspose.Pdf.Kit;
using System.IO;
using System.Drawing;
namespace ASPOSBarcodeConsoleApp
{
class Program
{
static void Main(string[] args)
{
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(@"C:\\inetpub\\www\\BarCode.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.Code39Standard);
while (barcodeReader.Read())
{
Console.WriteLine("Codetext found: " + barcodeReader.GetCodeText() + ", Symbology: " + barcodeReader.GetReadType().ToString());
}
// close the reader
barcodeReader.Close();
}
Console.Read();
}
}
}
v4.0.30319