Why You Should Use A Commercial Barcode SDK for Business

ZXing is probably the most popular open source barcode SDK in the world. The library is written in Java and now has been ported to C++, .NET, Python, Objective-C, PHP and some other programming languages. Because ZXing is free, many developers would like to build barcode scanning apps with it. However, it is not competent for complicated business cases especially for images with multiple barcodes. In this article, I will show how to create a .NET barcode reader step by step and compare the performance difference between ZXing.Net and Dynamsoft Barcode Reader.

ZXing vs. Dynamsoft Barcode SDK

Supported Barcode Types


UPC-A, UPC-E, EAN-8, EAN-13, Code 39, Code 93, Code 128, ITF, Codabar, MSI, RSS-14 (all variants), QR Code, Data Matrix, Aztec and PDF-417.

Dynamsoft Barcode Reader

Code 39, Code 93, Code 128, Codabar, EAN-8, EAN-13, UPC-A, UPC-E, Interleaved 2 of 5 (ITF), Industrial 2 of 5 (Code 2 of 5 Industry, Standard 2 of 5, Code 2 of 5), ITF-14, QRCode, DataMatrix and PDF417.

.NET Command Line Barcode Reader

Create a new Console Application in Visual Studio.

console barcode project

On the menu, Select Tools > NuGet Package Manager > Package Manager Console to install Dynamsoft Barcode Reader and ZXing.Net.

Install-Package Dynamsoft.DotNet.Barcode
Install-Package ZXing.Net

Alternatively, you can install DynamsoftBarcodeReader6.1.exe and then right-click references to import the library to the project.

dynamsoft barcode reader

Besides, you have to add System.Drawing framework.

dotnet drawing

List all files in an image folder:

string[] files = Directory.GetFiles(directory);

Load an image file to bitmap:

Bitmap barcodeBitmap = (Bitmap)Image.FromFile(file);

Note: The Image class does not support PDF format. If the input file is PDF, it will throw an exception.

Read multiple barcodes with ZXing:

ZXing.MultiFormatReader multiFormatReader = new ZXing.MultiFormatReader();
ZXing.Multi.GenericMultipleBarcodeReader multiBarcodeReader = new ZXing.Multi.GenericMultipleBarcodeReader(multiFormatReader);
LuminanceSource source = new BitmapLuminanceSource(bitmap);
ZXing.BinaryBitmap bBitmap = new ZXing.BinaryBitmap(new HybridBinarizer(source));
ZXing.Result[] zResults = multiBarcodeReader.decodeMultiple(bBitmap);

Read barcodes with Dynamsoft Barcode Reader:

Dynamsoft.Barcode.BarcodeReader reader = new Dynamsoft.Barcode.BarcodeReader();
reader.LicenseKeys = "LICENSE_KEY";
TextResult[] results = reader.DecodeBitmap(barcodeBitmap, "");

Use Stopwatch to monitor the time cost:

Stopwatch swDBR = Stopwatch.StartNew();
Console.WriteLine(swDBR.Elapsed.TotalMilliseconds + "ms");

Beautify the output by string format:

Console.WriteLine("{0, -10}{1, -20}{2, -20}", "DBR", "time: " + swDBR.Elapsed.TotalMilliseconds + "ms", " result count: " + results.Length);
Console.WriteLine("{0, -10}{1, -20}{2, -20}", "ZXing", "time: " + swZXing.Elapsed.TotalMilliseconds + "ms", " result count: " + zResults.Length);

We can also color the output to differ the results:

Console.BackgroundColor = ConsoleColor.Blue;
Console.WriteLine("{0, -10}{1, -20}{2, -20}", "ZXing", "time: " + swZXing.Elapsed.TotalMilliseconds + "ms", " result count: " + zResults.Length);
Console.BackgroundColor = ConsoleColor.Red;
Console.WriteLine("{0, -10}{1, -20}{2, -20}", "DBR", "time: " + swDBR.Elapsed.TotalMilliseconds + "ms", " result count: " + results.Length);

Build and run the application with testing images.

dbr-zxing.exe [image folder]

barcode sdk performance

According to the result, we can see when detecting multiple barcodes, ZXing performs terribly. Dynamsoft Barcode Reader as a commercial barcode SDK is much faster and more accurate. If you want to create a business solution, such as document scanning and management based on barcodes, you’d better choose a commercial barcode SDK rather than ZXing.

Source Code