Read and Write Barcodes in .NET - Demo Project on Github!

Posted on 2020-04-06 Nick Villalobos

New to LEADTOOLS? We've added some specific demos to GitHub to make it easier for you get started using our SDKs. We're going to highlight some of these in various blog posts over the next few weeks. First up, our Barcode demo for .NET. Powered by LEADTOOLS machine learning engine, the LEADTOOLS Barcode libraries provide a fast, robust, and easy-to-use API to detect, read, and write 1D and 2D barcodes.

Reading and generating barcodes in .NET has never been easier. With only 5 lines of code, you can have either a barcode scanner or barcode writer application ready. The LEADTOOLS Barcode namespace has many classes, but we're only going to talk about the BarcodeReader and BarcodeWriter class in this post.


BarcodeReader

BarcodeReader reader = engine.Reader;
BarcodeData[] barcodes = reader.ReadBarcodes(image, LeadRect.Empty, 0, null);
// Loop through all barcodes found
for (int i = 0; i < barcodes.Length; i++) 
{ 
	BarcodeData barcode = barcodes[i]; 
	Console.WriteLine($"Symbology: {barcode.Symbology}, Value: {barcode.Value}");
} 

BarcodeWriter


BarcodeEngine engine = new BarcodeEngine(); 
// Use the instance in BarcodeEngine directly, for example, write a UPCA barcode to an image: 
BarcodeData data = new BarcodeData(BarcodeSymbology.UPCA,"01234567890"); 
data.Bounds = new LeadRect(0, 0, 400, 200); 
engine.Write.WriteBarcode(image, data, null);

Git The Code!

Download the full project from the LEADTOOLS GitHub repository and begin reading and writing barcodes in .NET.

A license is required to run the code. Get your free evaluation license here!

Support

Need help getting this sample up and going? Contact our support team for free technical support! For pricing or licensing questions, you can contact our sales team (sales@leadtools.com) or call us at 704-332-5532.

LEADTOOLS Blog

LEADTOOLS Powered by Apryse,the Market Leading PDF SDK,All Rights Reserved