C# Imaging - Decode Interleaved 2 of 5 in C#.NET
Sample C# Code for Interleaved 2 of 5 Recognition from Document & Image.
Support Read barcode from PDF in C#.
C# Interleaved 2 of 5 Barcode Recognition
The barcode reader control library toolkit from RasterEdge DocImage SDK for .NET owns two impressive Interleaved 2 of 5 barcode reading & scanning features. Firstly, quickly read one or multiple Interleaved 2 of 5 barcode(s) from both document & image files using a few lines of C# code. Secondly, specify a smaller area in the image for Interleaved 2 of 5 barcode recognition using C#.NET.
Related .net document control helps:
asp.net edit pdf image:
ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net multipage tiff viewer: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
asp.net word document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net image viewer: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
asp.net dicom document viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net excel viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
asp.net mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
Interleaved 2 of 5, a continuous barcode type, is often used on 135 films and cartons of some products. And this barcode reader is developed under the guidance of latest established Interleaved 2 of 5 barcode standards and barcode specifications. Thus, it can be used as a tool to check whether scanned Interleaved 2 of 5 barcode is industry-standard.
Besides, this barcode reader control can also be used to read & decode other linear & 2d barcodes from document image files in C#.NET class application, like Code 39, Code 128, QR Code and UPC-A. Besides barcode reading & recognizing in Visual C#, RasterEdge DocImage SDK for .NET also contains a barcode generator add-on which can help you generate Interleaved 2 of 5 barcode using VB.NET code.
Interleaved 2 of 5 Barcode Reading Library Features
Developed in .NET framework application and contained in a compact library
Own compatibility with Visual Studio and .NET-based applications (Windows & Web Forms)
Read Interleaved 2 of 5 from raster image files accurately & quickly using C# code
Apply Interleaved 2 of 5 barcode reading functions into document processing projects
Interleaved 2 of 5 barcode detecting & scanning area can be specified using C# code
Decode all Interleaved 2 of 5 barcode from image files using one line of C# code
Decode the check digit of scanned Interleaved 2 of 5 barcode automatically using C#
Steps to Read/Scan Data Matrix from Image/PDF/TIFF/Office File
Load an image or a document(PDF, TIFF, Word, Excel, PowerPoint).
Get a Bitmap or BasePage used to decode or read barcode.
Set the barcode reader settings.
Call the following static method in BarcodeReader.cs to read or scan barcode from Bitmap or BasePage.
public static Barcode[] ReadBarcodes(ReaderSettings settings, BasePage page)
public static Barcode[] ReadBarcodes(ReaderSettings settings, Bitmap image)
The barcode information will be saved in the array of Barcode object. While, if you read barcodes information from the BasePage failed, you can try as follows:
Convert BasePage to Bitmap with higher resolution by Calling method ConvertToImage(int resolution) in the BasePage.cs:
//Convert page to bitmap.
//The default resolution is 96, if youo set the resolution higher, it will be better to read or scan barcode.
Bitmap bmp = page.ConvertToImage(192);
// read all barcodes in the page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(settings, bmp);
foreach (Barcode barcode in barcodes)
{
Console.WriteLine("Data: " + barcode.DataString);
}
|
If you want to have a try, please refer to the following demo codes.
Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:
If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.
If using x86, the platform target should be x86.
Interleaved 2 of 5 Barcode Reading from Image in C#
It is an easy task to read & decode one or multiple Interleaved 2 of 5 barcode(s) from image files and .NET image objects using this C#.NET barcode reader & decoder control from RasterEdge DocImage SDK for .NET. Supported raster image formats are png, jpeg, bmp, gif and tiff.
In this part, we will take Interleaved 2 of 5 barcode reading and recognition from PNG image files as examples. Using the sample C# code below, you can detect and decode all Interleaved 2 of 5 barcodes from target png images in .NET Framework applications (ASP.NET web site and Windows Forms).
Add necessary references to your C#.NET project. Right-click the project and select "Add Reference..." to locate and add the following DLLs as project references;
RasterEdge.Imaging.Basic.dll
RasterEdge.XImage.BarcodeScanner.dll
Use corresponding namespaces;
using RasterEdge.XImage.BarcodeScanner;
Bitmap bmp = new Bitmap(inputDirectory + "Sample_Barcode.png");
// config reader setting
ReaderSettings settings = new ReaderSettings();
// define the type of barcode to scan
settings.AddTypesToRead(BarcodeType.Interleaved2of5);
// read all barcodes in the document
Barcode[] barcodes = BarcodeReader.ReadBarcodes(settings, bmp);
foreach (Barcode barcode in barcodes)
{
Console.WriteLine("Data: " + barcode.DataString);
}
|
C#: DLLs for Interleaved 2 of 5 Barcode Scanning from Document(TIFF, PDF, Office)
In order to run the following demo codes reading Interleaved 2 of 5 barcode from document, the steps as follows are necessary.
Add references:
RasterEdge.Imaging.Basic.dll
RasterEdge.Imaging.Basic.Codec.dll
RasterEdge.Imaging.Processing.dll
RasterEdge.Imaging.Font.dll
RasterEdge.Imaging.Drawing.dll
RasterEdge.XImage.BarcodeScanner.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XImage.Raster.dll
Use corresponding namespaces;
using RasterEdge.XImage.BarcodeScanner;
using RasterEdge.Imaging.Basic;
Decode Interleaved 2 of 5 from TIFF Image File in C#
Following C# sample code allows users to read Interleaved 2 of 5 from TIFF image with RasterEdge .NET Barcode Reader.
Add references(Extra):
RasterEdge.XDoc.TIFF.dll
Use corresponding namespaces(Extra):
using RasterEdge.XDoc.TIFF;
// load TIFF document
TIFFDocument doc = new TIFFDocument(inputDirectory + "Sample_Barcode.tif");
// get the page you want to scan
BasePage page = doc.GetPage(0);
// set reader setting
ReaderSettings setting = new ReaderSettings();
// set type to read
setting.AddTypesToRead(BarcodeType.Interleaved2of5);
// read barcode from tiff page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);
foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);
// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
|
Interleaved 2 of 5 Barcode Recognition from C# PDF
Apart from the common Interleaved 2 of 5 barcode recognition functionality for PDF document, our C#.NET barcode reader & scanner library control also allows developers optimize Interleaved 2 of 5 barcode reading & scanning rate from PDF document based on different situations.
Add references(Extra):
RasterEdge.XDoc.PDF.dll
Use corresponding namespaces(Extra):
using RasterEdge.XDoc.PDF;
// load PDF document
PDFDocument doc = new PDFDocument(inputDirectory + "Sample_Barcode.pdf");
// get the page you want to scan
BasePage page = doc.GetPage(0);
// set reader setting
ReaderSettings setting = new ReaderSettings();
// set type to read
setting.AddTypesToRead(BarcodeType.Interleaved2of5);
// read barcode from PDF page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);
foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);
// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
|
Interleaved 2 of 5 Barcode Scanning from C# Word
As for the Interleaved 2 of 5 barcode reading & recognition from Word document page, the optimization of barcode scanning & detecting rate is also applicable.
Add references(Extra):
RasterEdge.XDoc.Word.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner.Office03.dll
Use corresponding namespaces(Extra):
using RasterEdge.XDoc.Word;
// load Word document
DOCXDocument doc = new DOCXDocument(inputDirectory + "Sample_Barcode.docx");
// get the page you want to scan
BasePage page = doc.GetPage(0);
// set reader setting
ReaderSettings setting = new ReaderSettings();
// set type to read
setting.AddTypesToRead(BarcodeType.Interleaved2of5);
// read barcode from Word page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);
foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);
// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
|
Interleaved 2 of 5 Barcode Decoding from C# Excel
All Interleaved 2 of 5 barcode images can be accurately decoded from specific Excel sheet using following sample C# code.
Add references(Extra):
RasterEdge.XDoc.Excel.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner.Office03.dll
Use corresponding namespaces(Extra):
using RasterEdge.XDoc.Excel;
// load Excel document
XLSXDocument doc = new XLSXDocument(inputDirectory + "Sample_Barcode.xlsx");
// get the page you want to scan
BasePage page = doc.GetPage(0);
// set reader setting
ReaderSettings setting = new ReaderSettings();
// set type to read
setting.AddTypesToRead(BarcodeType.Interleaved2of5);
// read barcode from Excel page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);
foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);
// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
|
Interleaved 2 of 5 Barcode Scanning from C# PowerPoint
Sample C# code to decode all Interleaved 2 of 5 barcodes included in the source PowerPoint slide.
Add references(Extra):
RasterEdge.XDoc.PowerPoint.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner.Office03.dll
Use corresponding namespaces(Extra):
using RasterEdge.XDoc.PowerPoint;
// load PowerPoint document
PPTXDocument doc = new PPTXDocument(inputDirectory + "Sample_Barcode.pptx");
// get the page you want to scan
BasePage page = doc.GetPage(0);
// set reader setting
ReaderSettings setting = new ReaderSettings();
// set type to read
setting.AddTypesToRead(BarcodeType.Interleaved2of5);
// read barcode from PowerPoint page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);
foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);
// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
|