C# UPC-A Reader Library
C# Imaging - Scan UPC-A Barcode in C#.NET
Visual C# Demo Code to Scan UPC-A on Image & Document.
C# Code to Scan UPC-A Barcode Overview
UPC-A is also known as Universal Product Code version A, UPC-A Supplement 5/Five-digit Add-On, UPC-A Supplement 2/Two-digit Add-On, which consists of 4 parts: number system, manufacturer code, product code and a check digit. UPC-A is the most widely used barcode in the United States as it is used extensively to identify consumer goods. The number system is the number to the left and outside of the bars.
Related .net document control helps:
asp.net edit pdf page:
ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net edit pdf text color:
ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net annotate pdf control:
ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
asp.net tiff viewer control: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
asp.net open word document in browser: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
RaterEdge C#.NET UPC-A barcode reading controls are designed to help developers and end-users to decode and scan UPC-A barcode on JPEG, BMP, TIFF, PNG & GIF images and PDF & Word document pages with high capabilities.
RaterEdge .NET Imaging Barcode Reader offers the most mature and complete barcode reading APIs for developers and users to create amazing, fully-featured barcode reading applications in record time to read and recognize linear and 2D barcodes from multiple Visual .NET applications, such as C#.NET, VB.NET, ASP.NET and .NET WinForms. This tutorial article mainly demonstrates the 1D UPC-A barcode reading on images and document pages in an easy way.
Besides, users who want to get the help of UPC-A barcode creating in C#.NET and more 1D barcodes reading tutorials in VB.NET can check here.
UPC-A Scanning Features in C#.NET
Easy to integrate UPC-A barcode reader into C#.NET application
Compatible with GS1 Barcode Standard for linear UPC-A scanning in C#.NET applications
Easily to read UPC-A two or five digits supplement barcodes to in C# code
Automatically scan 1D UPC-A barcodes check digit for in C#.NET project
Comprehensive reporting of the recognized barcode in C# code
Fully configurable UPC-A barcode recognition engine
Save the scanned UPC-A barcode with easy C#.NET APIs
Read UPC-A barcode from gif, jpeg, png, tiff and bitmap image formats
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.
UPC-A Scanning on Images in C#.NET
With RasterEdge Barcode Add-on SDK library, C#.NET users are able to read UPC-A barcode from images in only a few lines of C# codes. Our supported image formats includes: GIF, BMP, TIFF, PNG 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.UPCA);
// 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 UPC-A Barcode Scanning from Document(TIFF, PDF, Office)
In order to run the following demo codes reading UPC-A 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;
Recognize UPC-A from TIFF Image in C#.NET
Following C# sample code allows users to read UPC-A 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.UPCA);
// 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);
}
|
UPC-A Scanning on PDF in C#.NET
With RasterEdge premier and easy-to-use barcode reading dll, users have the ability to integrate a powerful solution for reading UPC-A barcode from documents. As you can see from the C#.NET demo code, there will be two steps for reading UPC-A barcode on PDF: first step is converting target PDF barcode pages into any supported images, and second step is reading UPC-A barcode from the transferred images.
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.UPCA);
// 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);
}
|
UPC-A Scanning on Word in C#.NET
Beside barcode reading on PDF, Word barcode reading is also completely available. Do as the same procedures as on PDF. Detailed guide is demonstrated in following C# example code.
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.UPCA);
// 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);
}
|
UPC-A Barcode Reading from Excel in C#.NET
This section aims to answer the question of how to read UPC-A barcode from Excel file programmatically.
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.UPCA);
// 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);
}
|
UPC-A Barcode Image Recognition from PPT in C#.NET
This C# UPC-A barcode reader SDK allows developers to recognize all barcodes from 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.UPCA);
// 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);
}
|