Generating a barcode with ZXing.Net

1. Installing ZXing.Net library.

Using nuget package installer install ZXing.Net libarary. Once installed you should be able to see zxing and zxing.presentation references.

2. Using ZXing library in a c# class. 

string content = barcodeNumber;

IBarcodeWriter writer = new BarcodeWriter
{
Format = BarcodeFormat.EAN_13,
Options= new ZXing.Common.EncodingOptions
{
Height=100,
Width =200,
Margin=2
}
};

Bitmap barcodeBitmap;
var barcode= writer.Write(content);
MemoryStream stream = new MemoryStream();
barcode.Save(stream, ImageFormat.Bmp);

Advertisements