C#: Online Guide
How To: Barcode Reader
EAN-8
EAN-8
  |  
Home ›› XImage.Barcode Reader ›› C# Barcode Reader: EAN-8

C# Imaging - Decode EAN-8 Barcode in C#.NET


C#.NET EAN-8 Barcode Reader to Decode EAN-8 on Image & Document




C#.NET EAN-8 Barcode Reader Overview



The EAN/UCC-8 linear barcode symbol, also known as European Article Number 8, UPC-8, GTIN-8, GS1-8, EAN/UCC-8, is used internationally to identify consumer goods, but is shorter than EAN-13 symbols. Unlike UPC-E that can be expanded back into a UPC-A symbol, EAN-8 cannot be expanded into an EAN-13 symbol.


Related .net document control helps:
c# asp.net excel document viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications
asp.net create pdf using c#: ASP.NET Create PDF Document Control: create, convert PDF file from Word, Excel, Tiff file formats in C# ASP.NET
c# asp.net text document viewer: C# HTML5 Viewer: Load, View, Convert, Annotate and Edit OpenOffice, CSV and Text file
c# asp.net sharepoint document viewer: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net edit pdf image using c#: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net mvc pdf editor using c#: ASP.NET MVC PDF Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
c# asp.net document redaction: Redact document ASP.NET: add, delete, apply redaction on PDF files in web browser using C#.net


RasterEdge .NET Barcode Reader can easily integrate barcode recognition into existing RasterEdge .NET Imaging SDK and build the easy-to-use linear and 2D barcode reading apps with Visual C#.NET code. Beside C#.NET project, RasterEdge .NET Barcode Reader also supports barcode scanning in ASP.NET, VB.NET and .NET WinForms applications. Different from ordinary barcode reader, RaserEdge Barcode Reader allows developers and end-users to read 1D and 2D barcodes from BMP, PNG, GIF, TIFF & JPEG images and PDF, Excel, PowerPoint & Word document pages in 100% accuracy and high speed.


RasterEdge C#.NET EAN-8 Decoder is the fundamental applications of RasterEdge Barcode Reader which is designed to empower developers and organizations with the abilities to scan and decode EAN 8 barcode on image and document. This EAN-8 Reader technology completely integrates with RasterEdge forms recognition and processing technology. We also prepare C#.NET EAN 8 creating and VB.NET EAN 8 reading tutorials to meet users' needs. For linear barcodes reading in ASP.NET and 2D barcodes reading in .NET WinForms, please link here.




C#.NET EAN-8 Barcode Reading Features



High-level EAN-8 barcode scanning library used in C#.NET application


Integrate EAN-8 scanner with RasterEdge .NET Imaging Processing controls


Incorporate C#.NET EAN-8 reader with PDF document SDK


Seamlessly combine C#.NET EAN-8 deader with Word document component


Scan multiple images EAN-8 barcodes in any orientation


Read EAN-8 barcode in any area of any document page


Multi-threaded support for running barcode reading


Decoded EAN-8 barcodes can be saved as common image formats using C# code




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.




C#.NET Code to Scan EAN-8 on Image



With following C# sample code, users can see that RasterEdge .NET Barcode Reader supports EAN-8 barcode scanning on multiple image files. The demo code below is for EAN-8 reading from PNG images, and other supported images are: BMP, TIFF, GIF and JPEG.


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.EAN8);

            //  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 EAN-8 Barcode Scanning from Document(TIFF, PDF, Office)



In order to run the following demo codes reading EAN-8 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;




C#.NET Code to Decode EAN-8 from TIFF Image File



Following C# sample code allows users to read EAN-8 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.EAN8);

            // 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);
            }





C#.NET Code to Scan EAN-8 on PDF



With powerful RasterEdge Barcode Reader, users can easily integrate EAN-8 Reader with PDF document SDK component to create an easy-to-use PDF document EAN-8 scanning APIs. And for reading EAN-8 barcode from PDF document, users should do like below tips:


First, convert the PDF document pages which has EAN-8 barcodes into images, the supported converting image formats include: TIFF, BMP, PNG, GIF and JPEG.


And then read EAN-8 barcode from the converted images directly.


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.EAN8);

            // 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);
            }





C#.NET Code to Scan EAN-8 on Word



The procedures of scanning EAN-8 barcode from Word document pages are similar to these of barcode reading from PDF document. Detailed C# snippet sample code can help you with an easier EAN-8 reading on Word.


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.EAN8);

            // 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);
            }





C# Code to Decode EAN-8 Barcode from Excel



All EAN-8 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.EAN8);

            // 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);
            }





C# Code to Scan EAN-8 Barcode from PowerPoint



Sample C# code to decode all EAN-8 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.EAN8);

            // 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);
            }