In this tutorial, I'll show you how to generate barcode and qrcode using the Zen.Barcode.Rendering.Framework library.
The Barcode rendering framework core quite simply encapsulates the native rendering of barcode symbologies without requiring third-party fonts. This framework makes it easy to define new symbologies and use the resultant images from web or windows forms applications in a variety of usage scenarios.
To make our demo, we will design a simple UI that allows you to create barcode and qrcode, then display it on the PictureBox control.
You need to install the Zen.Barcode.Core.dll from Nuget Package Manager or you can download it directly from https://www.nuget.org/packages/Zen.Barcode.Rendering.Framework/
Add the code to handle your windows forms application as below, then run your project to create a barcode or qrcode.
using System;
using System.Windows.Forms;
namespace AppDesign
{
public partial class frmBarcode : Form
{
public frmBarcode()
{
InitializeComponent();
}
private void btnBarcode_Click(object sender, EventArgs e)
{
Zen.Barcode.Code128BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
pic.Image = barcode.Draw(txtBarcode.Text, 40);
}
private void btnQRCode_Click(object sender, EventArgs e)
{
Zen.Barcode.CodeQrBarcodeDraw qrcode = Zen.Barcode.BarcodeDrawFactory.CodeQr;
pic.Image = qrcode.Draw(txtQRcode.Text, 40);
}
}
}