Prices from: $ 587.02

Aspose.BarCode for .NET Forum

Aspose.BarCode adnan_raf [USA] 24-Aug-2007 10:24:44

Can i read barcode from pdffile using the .net managed component? if yes then point be to some url and if no then what i need to do...?

Many thanks, adnan
Reply

RE: Aspose.BarCode shahzad.latif [Pakistan] 09-May-2012 19:23:32

Hi Adnan,

In order to read bar code from PDF file, you'll have to use two components: Aspose.Pdf (to extract bar code image from PDF), Aspose.Barcode (to read barcode from barcode image). You can use the following code to achieve your goal:

try
{
// set the license for Aspose.BarCode for .NET and Aspose.Pdf for .NET components
Aspose.BarCodeRecognition.License licenceBarCodeRecognition = new Aspose.BarCodeRecognition.License();
licenceBarCodeRecognition.SetLicense(@"Aspose.Total.lic");

Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
licensePdf.SetLicense(@"Aspose.Total.lic");

// bind the pdf document
PdfExtractor pdfExtractor = new PdfExtractor();
pdfExtractor.BindPdf(@"document.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();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}

If you need any further help, please do let us know.
Reply


Back to Aspose.BarCode for .NET

Official Supplier

As official and authorized distributors, we supply you with legitimate licenses directly from 300+ software publishers.

See all our Brands.

24/5 Customer Service

Need help to find the right software license, upgrade or renewal?

Call, Email or Live Chat with our experts.

Trusted for 20 Years

Over 580,000 licenses delivered to Developers, SysAdmins, Corporations, Governments & Resellers, worldwide.

Read more About Us.