Introduction:-
Here
I have explained how to generate Barcode and Qrcode in windows application.
Description:-
In my previous article I have explained How to lock a form or how to set a form as notmovable as well as fixed size .
Here I will explain how to
generate barcode as well as qrcode using C#.I have provided all the procedures
here to generate barcode and qrcode.Follow the following process
First download QRCODE GENERATOR LIBRARY from onbarcode.com
and then add reference to OnBarcode.Barcode.Winforms.dll to your windows
application.
using System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
OnBarcode.Barcode;
using
System.Drawing.Imaging;
namespace DRAWBARCODEAPP
{
public
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs
e)
{
}
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);
}
private void
GenerateBacode(string _data, string _filename)
{
Linear barcode = new
Linear();
barcode.Type = BarcodeType.CODE11;
barcode.Data = _data;
barcode.drawBarcode(_filename);
}
private void
Form1_Load_1(object sender, EventArgs e)
{
}
private void
button1_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.ShowDialog();
textBox2.Text = sfd.FileName.ToString()+".gif";
}
private void
button2_Click(object sender, EventArgs e)
{
GenerateBacode(textBox1.Text, textBox2.Text);
}
private void
button3_Click(object sender, EventArgs e)
{
GenerateQrcode(textBox1.Text, textBox2.Text);
}
}
}
Now Take look on the Windows form:-
After running this form it will display as
By click on Barcode Button it will create following Jpg image
By click on Qrcode it will create following jpg image
As I have explained above,you will generate the same Barcode and Qrcode image as per your requirements.
Hope you will like this article.
Keep reading my posts……
Thanks Shibashish Mohanty
No comments:
Post a Comment
Please don't spam, spam comments is not allowed here.