Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
795
Barcode reader returning empty value for tiff file
posted

Hi,

Reading Tiff file:

---------------------

I am trying to read barcode of a multipage tiff file using the below code. But it is returning empty string after reading the page. I have attached the tiff file with this post. Please advise  me what is wrong in this code and why it is not able to read the barcodes available in the page.

Reading Pdf file:

--------------------

Apart from the tiff, I want to read barcodes from pdf fiiles. Please what are the APIs which support reading barcodes from PDF files in infragistics? If possible pls provide some code samples to read barcodes from pdf files.

The below code reads bar code from tiff file.

using System;

 

using

 

 

System.Collections.Generic;

using

 

 

System.Linq;

using

 

 

System.Text;

using

 

 

System.IO;

using

 

 

System.Windows.Media.Imaging;

//using System.Drawing;

using

 

 

System.Windows;

using

 

 

System.Windows.Controls;

//using System.Windows.Media;

using

 

 

Infragistics.Controls.Barcodes;

namespace

 

 

ConsoleApplication1

{

 

 

class Program

{

 

 

static void Main(string[] args)

{

 

 

Stream imageStreamSource = new FileStream(@"C:\Data\Srirangam\test.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

 

 

TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

 

 

BitmapSource bitmapSource = decoder.Frames[1];

 

 

BarcodeReader barReader = new BarcodeReader();

barReader.BarcodeOrientation =

 

SymbolOrientation.Unspecified;

barReader.MaxNumberOfSymbolsToRead = 5;

barReader.DecodeComplete +=

 

new EventHandler<ReaderDecodeArgs>(barReader_DecodeComplete);

barReader.Decode(bitmapSource,

 

Symbology.All);

}

 

 

static void barReader_DecodeComplete(object sender, ReaderDecodeArgs e)

{

 

 

String barValue = e.Value;

 

 

Console.WriteLine(barValue);

}

}

}

 

using

 

 

System.Collections.Generic;

using

 

 

System.Linq;

using

 

 

System.Text;

using

 

 

System.IO;

using

 

 

System.Windows.Media.Imaging;

//using System.Drawing;

using

 

 

System.Windows;

using

 

 

System.Windows.Controls;

//using System.Windows.Media;

using

 

 

Infragistics.Controls.Barcodes;

namespace

 

 

ConsoleApplication1

{

 

 

class Program

{

 

 

static void Main(string[] args)

{

 

 

Stream imageStreamSource = new FileStream(@"C:\Data\Srirangam\test.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

 

 

TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

 

 

BitmapSource bitmapSource = decoder.Frames[1];

 

 

BarcodeReader barReader = new BarcodeReader();

barReader.BarcodeOrientation =

 

SymbolOrientation.Unspecified;

barReader.MaxNumberOfSymbolsToRead = 5;

barReader.DecodeComplete +=

 

new EventHandler<ReaderDecodeArgs>(barReader_DecodeComplete);

barReader.Decode(bitmapSource,

 

Symbology.All);

}

 

 

static void barReader_DecodeComplete(object sender, ReaderDecodeArgs e)

{

 

 

String barValue = e.Value;

 

 

Console.WriteLine(barValue);

}

}

}

using

 

 

System.Collections.Generic;

using

 

 

System.Linq;

using

 

 

System.Text;

using

 

 

System.IO;

using

 

 

System.Windows.Media.Imaging;

//using System.Drawing;

using

 

 

System.Windows;

using

 

 

System.Windows.Controls;

//using System.Windows.Media;

using

 

 

Infragistics.Controls.Barcodes;

namespace

 

 

ConsoleApplication1

{

 

 

class Program

{

 

 

static void Main(string[] args)

{

 

 

Stream imageStreamSource = new FileStream(@"C:\Data\Srirangam\test.tif", FileMode.Open, FileAccess.Read, FileShare.Read);

 

 

TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

 

 

BitmapSource bitmapSource = decoder.Frames[1];

 

 

BarcodeReader barReader = new BarcodeReader();

barReader.BarcodeOrientation =

 

SymbolOrientation.Unspecified;

barReader.MaxNumberOfSymbolsToRead = 5;

barReader.DecodeComplete +=

 

new EventHandler<ReaderDecodeArgs>(barReader_DecodeComplete);

barReader.Decode(bitmapSource,

 

Symbology.All);

}

 

 

static void barReader_DecodeComplete(object sender, ReaderDecodeArgs e)

{

 

 

String barValue = e.Value;

 

 

Console.WriteLine(barValue);

}

}

}