.NET Core Barcode Reader & Scanner Library

Decode, decipher linear & 2d barcode images for .NET Core applications

Scan and Read Linear & 2D Barcode Images in .NET Core, ASP.NET, C#, VB.NET Core Applications

    This document explains how to use .NET Core Barcode Reader to scan and read barcodes in image files.

    With an easy-to-use design purpose, our software doesn't need any activation code or registrion code. And ONBARCODE grants to you to use this evaluation package, on one computer, for Evaluation purposes only within 30 days.

     For trial version only, we will randomly print the First character in the output barcode data.

    Once you ordered any license of the product, we will email you OnBarcode.Barcode.BarcodeScanner.dll production version as soon as possible.





Installation
Top

Supported .NET Version

  • .NET 7
  • .NET 6
  • .NET 5
  • .NET Core 3.1
  • .NET Core 2.1

Choose Dll

  1. /Dll/{.net core version}/OnBarcode.Barcode.BarcodeScanner.dll

If you are using .NET 5 or .NET 6 on non-Windows (such as Linux, MacOS) operating system, you'd better choose dll based on SkiaSharp. The dll is located at /Dll/{.net core version}/Skia/OnBarcode.Barcode.BarcodeScanner.dll

https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only


Install dll Component

  1. Copy OnBarcode.Barcode.BarcodeScanner.dll to your .NET Core project folder.
    Please note that you don't need to copy dll to .NET bin directory, as the .NET build tools will do it for you.

  2. You need manually add System.Drawing.Common to .NET Core project reference.

How to Scan and Read Barcode Images in your .NET Core Project?
Top

Step 1: add a new Visual C# .NET Core Console App (.NET Core) project.

Remarks:

  • Target framework: .NET Core 2.0 or later.
  • Assembly "OnBarcode.Barcode.BarcodeScanner.dll" is rely on "System.Drawing.Common" (Version 4.5.0), which should be added by manually.

Step 2: Select "Add Reference..." in the "Dependencies" menu to open the "Reference Manage" dialog.





Step 3: Browser the target assembly "OnBarcode.Barcode.Common.dl" and add it to the project by clicking "OK".





Step 4: Select "Manage NuGet Packages..." in the "Dependencies" menu to open the "NuGet Package Manager" tab.





Step 5: Select "Browse" tab and search the NuGet package "System.Drawing.Common" in the Package source "nuget.org"; and then Install the System.Drawing.Common Version 4.5.0 to the project.





Step 6: Create a simple barcode in C#

using OnBarcode.Barcode.BarcodeScanner;



String inputFilePath = @"D:\Linear.CS.png";
String[] result = BarcodeScanner.Scan(inputFilePath, BarcodeType.Code128);
if (result.Length > 0)
{
    foreach (String msg in result)
    {
        Console.WriteLine("Barcode Message: '" + msg + "'");
    }
}
else
{
    Console.WriteLine("No Barcode Found!");
}
Console.WriteLine("PRESS ANY KEY TO EXIT:");
Console.ReadLine();









Advanced Features
Top

1. Scan barcodes from the image documents

Read barcodes from image is a simple task with barcode reader for .net control. Here is the sample demo code in C# and VB.NET to scan barcodes from image files.

C# Demo Code:

	String[] barcodes = BarcodeScanner.Scan("code39image.gif", BarcodeType.Code39);

VB.NET Demo Code:

	Dim barcodes() As string = BarcodeScanner.Scan("code39image.gif", BarcodeType.Code39)

Pass your barcode image file, and barcode type to BarcodeScanner.Scan method, and it will scan the image and return all barcodes found.

2. Scan barcodes from .NET image object

To scan barcodes from System.Drawing.Bitmap object (C#) or Dim bmp As System.Drawing.Bitmap (VB.NET).

C# Demo Code:

	System.Drawing.Bitmap objImage = ...
	String[] barcodes = BarcodeScanner.Scan(objImage, BarcodeType.Code39);

VB.NET Demo Code:

	Dim bmp As System.Drawing.Bitmap = ...
	Dim barcodes() As string = BarcodeScanner.Scan(bmp, BarcodeType.Code39)

3. Scan barcodes from the defined area within the image

To scan barcodes from defined area in the image document. The following C# and VB.NET demo codes will scan user defined area (left top point is [0, 0], right bottom
point is [200, 300]) from the image document.

C# Demo Code:

	List<SRegion> areas = new List<SRegion>();
	SRegion area = new SRegion(0, 0, 50, 60);
	areas.Add(area);
	String[] barcodes = BarcodeScanner.ScanRegions("code39image.gif", BarcodeType.Code39, areas);

VB.NET Demo Code:

	Dim areas As New List(Of SRegion)()
	Dim area As New SRegion(0, 0, 200, 300)
	areas.Add(area) 
	Dim barcodes As [String]() = BarcodeScanner.ScanRegions("code39image.gif", BarcodeType.Code39, areas);

4. Scan maximum 1 barcode from the image

If there is maximum one barcode in the image file, to improve the reading speed, you can use the following method to scan the barcode.

C# Demo Code:

	String[] barcodes = BarcodeScanner.ScanSingleBarcode("code39image.gif", BarcodeType.Code39);

VB.NET Demo Code:

	Dim barcodes As [String]() = BarcodeScanner.ScanSingleBarcode("code39image.gif", BarcodeType.Code39)

5. Scan and get more information about the barcode

Besides barcode data, if you also need barcode location and barcode rotation information, you can call "ScanInDetails" method.

C# Demo Code:

	BarcodeDetail[] barcodeDetails = BarcodeScanner.ScanInDetails("code39image.gif", BarcodeType.Code39);

VB.NET Demo Code:

	Dim barcodeDetails As BarcodeDetail() = BarcodeScanner.ScanInDetails("code39image.gif", BarcodeType.Code39)
Barcode Types Supported
Top
public enum BarcodeType
{
    AustraliaPost = 0,                 EAN8 = 7,                          ITF14 = 14,                    RM4SCC = 21,    
    Codabar = 1,                       EAN13 = 8,                         Leitcode = 15,                 UPCA = 22,   
    Code39 = 2,                        Identcode = 9,                     PatchCode = 16,                UPCE = 23,    
    Code39Extension = 3,               IntelligentMail = 10,              PDF417 = 17,                   All = 999   
    Code93 = 4,                        Interleaved2of5 = 11,              Planet = 18,                   
    Code128 = 5,                       ISBN = 12,                         Postnet = 19,
    DataMatrix = 6,                    ISSN = 13,                         QRCode = 20,
                                                   
}




OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.