How to Create Barcode & QR Code Images in C#

In this tutorial, we explore creating barcode and QR code images in C# using the Iron Barcode library. Starting with a program CS file, we access Iron Barcode's features by importing its namespace. We then create a QR code embedding the Iron Barcode URL, defining a size of 500 pixels and a high error correction level. The tutorial demonstrates saving the generated barcode in formats like JPEG, GIF, PNG, TIFF, and as a Windows bitmap. The efficiency of Iron Barcode ensures clear, readable barcodes in any format, emphasizing its versatility. The video encourages viewers to try Iron Barcode's 30-day trial to experience its capabilities firsthand. This guide serves as an excellent resource for developers looking to integrate barcode generation into their applications effortlessly.

Here is an example of how you can implement the QR code generation in C# using Iron Barcode:

using IronBarCode; // Import the Iron Barcode namespace

namespace BarcodeGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // Define the URL to be encoded in the QR code
            string url = "https://ironsoftware.com";

            // Generate a QR code with the specified URL, with a size of 500 pixels, and with a high error correction level
            var qrCode = QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QRCodeErrorCorrectionLevel.High);

            // Save the generated QR code in different formats
            qrCode.SaveAsPng("QRCode.png");  // Save as PNG
            qrCode.SaveAsJpeg("QRCode.jpeg"); // Save as JPEG
            qrCode.SaveAsGif("QRCode.gif");  // Save as GIF
            qrCode.SaveAsTiff("QRCode.tiff"); // Save as TIFF
            qrCode.SaveAsBitmap("QRCode.bmp"); // Save as Bitmap
        }
    }
}
using IronBarCode; // Import the Iron Barcode namespace

namespace BarcodeGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // Define the URL to be encoded in the QR code
            string url = "https://ironsoftware.com";

            // Generate a QR code with the specified URL, with a size of 500 pixels, and with a high error correction level
            var qrCode = QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QRCodeErrorCorrectionLevel.High);

            // Save the generated QR code in different formats
            qrCode.SaveAsPng("QRCode.png");  // Save as PNG
            qrCode.SaveAsJpeg("QRCode.jpeg"); // Save as JPEG
            qrCode.SaveAsGif("QRCode.gif");  // Save as GIF
            qrCode.SaveAsTiff("QRCode.tiff"); // Save as TIFF
            qrCode.SaveAsBitmap("QRCode.bmp"); // Save as Bitmap
        }
    }
}
Imports IronBarCode ' Import the Iron Barcode namespace

Namespace BarcodeGenerator
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			' Define the URL to be encoded in the QR code
			Dim url As String = "https://ironsoftware.com"

			' Generate a QR code with the specified URL, with a size of 500 pixels, and with a high error correction level
			Dim qrCode = QRCodeWriter.CreateQrCode(url, 500, QRCodeWriter.QRCodeErrorCorrectionLevel.High)

			' Save the generated QR code in different formats
			qrCode.SaveAsPng("QRCode.png") ' Save as PNG
			qrCode.SaveAsJpeg("QRCode.jpeg") ' Save as JPEG
			qrCode.SaveAsGif("QRCode.gif") ' Save as GIF
			qrCode.SaveAsTiff("QRCode.tiff") ' Save as TIFF
			qrCode.SaveAsBitmap("QRCode.bmp") ' Save as Bitmap
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

Further Reading: How to Create Barcode Images

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he says it’s one of his favorite aspects of working with Iron Software. Jordi grew up in Miami, Florida and studied Computer Science and Statistics at University of Florida.
< PREVIOUS
How to Customize and Add Logos to QR Codes in C#
NEXT >
How to Create Barcodes as PDFs in C#