SIGN UP MEMBER LOGIN:    
ARTICLE

Generating Barcode in C#

Posted by Krishna Garad Articles | C# Language August 26, 2011
In this article we will learn hot to generate barcode from C# windows application using QRCODE GENERATOR LIBRARY.
Reader Level:
Download Files:
 

Introduction:
 
In this article we will learn hot to generate barcode from C# windows application using QRCODE GENERATOR LIBRARY.
 
Background:

In so many situation we need to generate the barcode images for products using C# we can generate this barcode images and print on the products then after we can scan those barcode image and get the description like price,image etc... from the database.

Here I'll discuss how to generate the barcode using C#.

What Is Barcode?

Barcode or Qrcode is the technique to encode the data ex. Text,url or etc into encoded image format to provide confidential access to the data. In shopping malls you may see they are scaning those barcode prited on products and then get the description of the perticuler product from their server database. For those kind of activity we have to generate those barcode.

Here we will learn to generate barcode as well as qrcode images also.

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:

Barcode in C#

Qrcode:

qrcode in C#

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Gauge for SharePoint
Become a Sponsor