Background
I surfed the internet one day and found a barcode library. The description in the library said that it can generate barcode images and along with it, can scan an image for the barcodes. I got interested in it, so I checked its methods and generated the barcode images using the barcode library.
Introduction
The library provides two important classes to generate the barcode images: one is BarcodeSettings and the other one is the BarCodeGenerator. BarcodeSettings provides properties to set the barcode type, the text to encode, colors, fonts and other things. To learn more check its definition. And a BarCodeGenerator generates barcode images using the BarcodeSettings instance.
Sample Code
To use the barcode library, download it here at freebarcode and add it to your project. And the code to generate the barcodes are as follows:
static void Main(string[] args)
{
BarcodeSettings barsetting = new BarcodeSettings();
barsetting.Data = "9787508351520";
barsetting.Type = BarCodeType.EAN13;
barsetting.ShowTextOnBottom = true;
BarCodeGenerator bargenerator = new BarCodeGenerator(barsetting);
Image barcodeimage = bargenerator.GenerateImage();
barcodeimage.Save("barcode_1.png");
System.Diagnostics.Process.Start("barcode_1.png");
}
Outcome
Here is the barcode that gets generated using the above code:
I hope this article is helpful.