Reputation: 25
I have created one web application using MVC Framework, we want to generate multiple barcode for Item, each and every barcode should be unique. we are using Asp.net c# MVC 5.0 Without Image and External Fonts. Thanks
Upvotes: 1
Views: 2250
Reputation: 13
Let's take a look step by step.
Step 1: Download QRCODE GENERATOR LIBRARY from onbarcode.com.
Step 2: Open Visual Studio - Create New Project - Windows Form.
Step 3: Add reference to OnBarcode.Barcode.Winforms.dll.
Step 4: Design form with some input fields for accepting data to encode and the targeted location to save barcode generated image.
Step 5: To generate Barcode as well as Qrcode images write two differen methods as follows.
private void GenerateBacode(string _data, string _filename)
{
Linear barcode = new Linear();
barcode.Type = BarcodeType.CODE11;
barcode.Data = _data;
barcode.drawBarcode(_filename);
}
private void GenerateQrcode(string _data, string _filename)
{
QRCode qrcode = new QRCode();
qrcode.Data = _data;
qrcode.DataMode = QRCodeDataMode.Byte;
qrcode.UOM = UnitOfMeasure.PIXEL;
qrcode.X = 3;
qrcode.LeftMargin = 0;
qrcode.RightMargin = 0;
qrcode.TopMargin = 0;
qrcode.BottomMargin = 0;
qrcode.Resolution = 72;
qrcode.Rotate = Rotate.Rotate0;
qrcode.ImageFormat = ImageFormat.Gif;
qrcode.drawBarcode(_filename);
}
Conclusion:
In this way you can generate barcode and qrcode images in C#. Output will look like bellow
Barcode: https://i.sstatic.net/EhzBE.png
Qrcode: https://i.sstatic.net/EhzBE.png
Upvotes: 1