C# Codabar Barcode Reader Library
C# Imaging - Read Codabar Barcode in C#.NET


C#.NET Codabar Barcode Reading from Image & Document






C#.NET Codabar Reader Overview



RasterEdge Image Barcode Reader SDK provides developers and end users with fast, accurate and professional linear (including Codabar) and 2d barcodes recognition capabilities for Visual .NET applications, including C#.NET, VB.NET, ASP.NET and .NET WinForms. Our C#.NET barcode reader can read all barcodes from images and document pages and then returns the string value of each barcode recognized quickly and precisly. While Codabar barcode detecting and decoding, RasterEdge .NET Imaging SDK also can detect the orientation, position of checksum character of the recognized Codabar barcode automatically.


Related .net document control helps:
asp.net dicom library: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net pdf viewer using c#: ASP.NET PDF Viewer Control: view, navigate, zoom Adobe PDF document in C# ASP.NET
asp.net edit pdf text using c#: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net document viewer example: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net pdf document viewer c#: ASP.NET PDF Document Viewer in C#: open, display, view, annotate, redact Adobe PDF files online in ASP.NET MVC & WebForm...
asp.net mvc word viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net edit pdf page using c#: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#


RasterEdge barcode reader supports decoding Codabar linear barcode from images and document pages in high perfomance. For users in Visual Basic .NET project, please have a look of reading image barcode in VB.NET project and if you want to see Codabar creating in C#.NET, please do have a link.




C# Codabar Reading Feature List



Easy to use and integrate specifically for Visual C#.NET applications


Scan Codabar on images with fastest recognition rate in C#.NET


C# code to decode Codabar from PDF, Word, Excel or PowerPoint document


Recognize vital Codabar data, location, and orientation, etc.


Return Codabar barcode colors: foreground and background color in C#.NET


Provide the quickest decoding of printed Codabar


Runtime royalty free options available for desktop or server deployments




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.




Scan Codabar from Image in C#.NET



RasterEdge .NET barcode component is very easy to use and designed specifically for C#.NET project. Developers and end users can decode and scan Codabar barcode images from JPEG, BMP, PNG, TIFF & GIF. Following demo code is for Codabar reading from PNG images.


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

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



In order to run the following demo codes reading Codabar 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 Codabar from TIFF Image File in C#.NET



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

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





Scan Codabar from PDF in C#.NET



Reading Codabar barcode from PDF, users need to convert PDF barcode document into image barcode first. You can refer to below sample C# class code to convert PDF to image and then scan Codabar barcode. And the needed RasterEdge .NET assemblies are RasterEdge.Imaging.Basic.dll, RasterEdge.Imaging.PDF.dll and RasterEdge.Imaging.Barcode.Scanner.dll.


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

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





Scan Codabar from Word in C#.NET



Like scanning Codabar from PDF document, users also need the three relative RasterEdge .NET references to finish the Codabar reading from Word documents pages. The detailed steps are:


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

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





Decode Codabar from Excel Doc in C#.NET



All Codabar 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.Codabar);

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





Read Codabar from PowerPoint in C#.NET



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

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