IRONSOFTWAREHOME

Generate QR Codes in C# - Complete Tutorial for .NET Developers

Jacob Mellor, Chief Technology Officer @ Team Iron
Jacob Mellor
Updated: August 2, 2026

Need to generate QR codes in your C# application? This tutorial shows you exactly how to create, customize, and verify QR codes using IronBarcode - from simple one-line implementations to advanced features like logo embedding and binary data encoding.

Whether you're building inventory systems, event ticketing platforms, or contactless payment solutions, you'll learn how to implement professional-grade QR code functionality in your .NET applications.

Quickstart: One-Line QR Code Creation with IronBarcode

Ready to generate a QR Code fast? Here's how you can use IronBarcode's QRCodeWriter API to produce a QR code in just one line of code - customization is optional but powerful.

  1. 1Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. 2Copy and run this code snippet.

    var qr = QRCodeWriter.CreateQrCode("https://ironsoftware.com/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium); qr.SaveAsPng("MyQR.png");
    C#
  3. 3Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial
    arrow pointer

How Do I Install a QR Code Library in C#?

Install IronBarcode using the NuGet Package Manager with this simple command:

PM > Install-Package BarCode

Install via NuGet

Alternatively, download the IronBarcode DLL directly and add it as a reference to your project.

Import Required Namespaces

Add these namespaces to access IronBarcode's QR code generation features:

using IronBarCode;

How Can I Create a Simple QR Code in C#?

Generate a QR code with just one line of code using IronBarcode's CreateQrCode method:

using IronBarCode;

// Generate a Simple BarCode image and save as PDF
QRCodeWriter.CreateQrCode("hello world", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium).SaveAsPng("MyQR.png");

The CreateQrCode method accepts three parameters:

  • Text content: The data to encode (supports URLs, text, or any string data)
  • Size: Pixel dimensions for the square QR code (500x500 in this example)
  • Error correction: Determines readability in suboptimal conditions (Low, Medium, Quartile, or High)

Higher error correction levels enable QR codes to remain readable even when partially damaged or obscured, though they result in denser patterns with more data modules.

Standard QR code generated with IronBarcode in C# A basic QR code containing "hello world" text, generated at 500x500 pixels with medium error correction

How Do I Add a Logo to My QR Code?

Embedding logos in QR codes enhances brand recognition while maintaining scannability. IronBarcode automatically positions and sizes logos to preserve QR code integrity:

using IronBarCode;
using IronSoftware.Drawing;

// You may add styling with color, logo images or branding:
QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode myQRCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo);
myQRCodeWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen);

// Logo will automatically be sized appropriately and snapped to the QR grid.
myQRCodeWithLogo.SaveAsPng("myQRWithLogo.png");

The CreateQrCodeWithLogo method intelligently handles logo placement by:

  • Automatically sizing the logo to maintain QR code readability
  • Positioning it within the quiet zone to avoid data corruption
  • Preserving the logo's original colors when changing QR code colors

This approach ensures your branded QR codes remain fully functional across all scanning devices and applications.

QR code with embedded Visual Studio logo QR code featuring the Visual Studio logo, demonstrating IronBarcode's automatic logo sizing and positioning

How Can I Export QR Codes to Different Formats?

IronBarcode supports multiple export formats for different use cases. Export your QR codes as images, PDFs, or HTML files:

using IronBarCode;

// You may add styling with color, logo images or branding:
QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode myQRCodeWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo);

myQRCodeWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);

// Save as PDF
myQRCodeWithLogo.SaveAsPdf("MyQRWithLogo.pdf");

// Also Save as HTML
myQRCodeWithLogo.SaveAsHtmlFile("MyQRWithLogo.html");

Each format serves specific purposes:

  • PDF: Ideal for printable documents and reports
  • HTML: Perfect for web integration without external dependencies
  • PNG/JPEG: Standard image formats for versatile usage

How Do I Verify QR Code Readability After Customization?

Color modifications and logo additions can impact QR code scannability. Use the Verify() method to ensure your customized QR codes remain readable:

using IronBarCode;
using IronSoftware.Drawing;
using System;

// Verifying QR Codes
QRCodeLogo qrCodeLogo = new QRCodeLogo("visual-studio-logo.png");
GeneratedBarcode MyVerifiedQR = QRCodeWriter.CreateQrCodeWithLogo("https://ironsoftware.com/", qrCodeLogo);

MyVerifiedQR.ChangeBarCodeColor(System.Drawing.Color.LightBlue);

if (!MyVerifiedQR.Verify())
{
    Console.WriteLine("\t LightBlue is not dark enough to be read accurately.  Lets try DarkBlue");
    MyVerifiedQR.ChangeBarCodeColor(Color.DarkBlue);
}
MyVerifiedQR.SaveAsHtmlFile("MyVerifiedQR.html");

// open the barcode html file in your default web browser
System.Diagnostics.Process.Start("MyVerifiedQR.html");

The Verify() method performs a comprehensive scan test on your QR code. This ensures compatibility across different scanning devices and lighting conditions before deployment.

Verified QR code with dark blue coloring and Visual Studio logo A successfully verified QR code in dark blue, demonstrating proper contrast for reliable scanning

How Can I Encode Binary Data in QR Codes?

QR codes excel at storing binary data efficiently. This capability enables advanced applications like encrypted data transfer, file sharing, and IoT device configuration:

using IronBarCode;
using System;
using System.Linq;

// Convert string to binary data
byte[] binaryData = System.Text.Encoding.UTF8.GetBytes("https://ironsoftware.com/csharp/barcode/");

// Create QR code from binary content
QRCodeWriter.CreateQrCode(binaryData, 500).SaveAsPng("MyBinaryQR.png");

// Read and verify binary data integrity
var myReturnedData = BarcodeReader.Read("MyBinaryQR.png").First();

// Confirm data matches original
if (binaryData.SequenceEqual(myReturnedData.BinaryValue))
{
    Console.WriteLine("Binary Data Read and Written Perfectly");
}
else
{
    throw new Exception("Data integrity check failed");
}

Binary encoding in QR codes offers several advantages:

  • Efficiency: Stores data in compact binary format
  • Versatility: Handles any data type (files, encrypted content, serialized objects)
  • Integrity: Preserves exact byte sequences without encoding issues

This feature distinguishes IronBarcode from basic QR code libraries, enabling sophisticated data exchange scenarios in your applications.

QR code containing binary encoded data QR code storing binary data, demonstrating IronBarcode's advanced encoding capabilities

How Do I Read QR Codes in C#?

IronBarcode provides flexible QR code reading capabilities. Here's the simplest approach:

using IronBarCode;
using System;
using System.Linq;

// Read QR code with optimized settings
BarcodeResults result = BarcodeReader.Read("QR.png", new BarcodeReaderOptions() { 
    ExpectBarcodeTypes = BarcodeEncoding.QRCode 
});

// Extract and display the decoded value
if (result != null && result.Any())
{
    Console.WriteLine(result.First().Value);
}
else
{
    Console.WriteLine("No QR codes found in the image.");
}

For more complex scenarios requiring fine-tuned control:

using IronBarCode;
using System;
using System.Linq;

// Configure advanced reading options
BarcodeReaderOptions options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Faster,           // Optimize for speed
    ExpectMultipleBarcodes = false,        // Single QR code expected
    ExpectBarcodeTypes = BarcodeEncoding.QRCode, // QR codes only
    Multithreaded = true,                  // Enable parallel processing
    MaxParallelThreads = 4,                // Utilize multiple CPU cores
    RemoveFalsePositive = true,            // Filter out false detections
    ImageFilters = new ImageFilterCollection() // Apply preprocessing
    {
        new AdaptiveThresholdFilter(),    // Handle varying lighting
        new ContrastFilter(),              // Enhance contrast
        new SharpenFilter()                // Improve edge definition
    }
};

// Read with advanced configuration
BarcodeResults result = BarcodeReader.Read("QR.png", options);

These advanced reading options enable reliable QR code detection in challenging conditions like poor lighting, image distortion, or low-quality prints.

What's Next for QR Code Development?

Now that you've mastered QR code generation with IronBarcode, explore these advanced topics:

Download Resources

Access the complete source code and examples:

API Documentation

Explore the complete feature set in the API reference:

Alternative: IronQR for Advanced QR Applications

For projects requiring cutting-edge QR code capabilities, consider IronQR - Iron Software's specialized QR code library featuring machine learning-powered reading and advanced generation options.

Ready to implement QR codes in your .NET application? Start your free trial or download IronBarcode today.

Frequently Asked Questions

What is IronBarcode and how can it help with QR code generation?

IronBarcode is a .NET library by Iron Software designed for generating and customizing QR codes, allowing developers to implement professional-grade QR code functionality in .NET applications with features such as logo embedding and binary data encoding.

How can I create a QR code in C# using IronBarcode?

To create a QR code with IronBarcode, you can use the `QRCodeWriter.CreateQrCode` method. This method takes text content, size, and error correction level as parameters and generates a QR code that can be saved in various formats like PNG.

Can I customize the appearance of my QR code using IronBarcode?

Yes, IronBarcode allows for extensive customization of QR codes, including changing colors, embedding logos, and adjusting sizes. This customization helps maintain QR code integrity and enhances brand recognition.

How do I verify the readability of a customized QR code?

You can use IronBarcode's `Verify()` method to test the readability of a QR code, ensuring it is scannable across different devices and under various lighting conditions, even after applying customizations like color changes or logo additions.

What export formats are available for QR codes generated with IronBarcode?

IronBarcode supports exporting QR codes to multiple formats, including PNG, PDF, and HTML, catering to different use cases such as web integration, printed documents, and digital sharing.

How can I encode binary data in a QR code using IronBarcode?

You can use IronBarcode to efficiently encode binary data in QR codes, supporting advanced applications like encrypted data transfer and IoT device configuration by preserving exact byte sequences.

How can I read QR codes in C# with IronBarcode?

IronBarcode offers flexible QR code reading capabilities through methods like `BarcodeReader.Read`, supporting basic decoding and advanced configurations such as multithreading, to enhance accuracy and speed in various conditions.

What are the steps to install IronBarcode in a C# project?

To install IronBarcode, use the NuGet Package Manager with the command provided in the tutorial, or download the IronBarcode DLL directly and add it as a reference to your C# project.

How does IronBarcode handle logo placement in QR codes?

IronBarcode's `CreateQrCodeWithLogo` method automatically sizes and positions logos within the QR code's quiet zone, maintaining readability and avoiding data corruption. This ensures the QR code remains fully functional and scannable.

What are some advanced features of IronQR, Iron Software's specialized QR code library?

IronQR offers cutting-edge QR code capabilities including machine learning-powered reading and generation options, suitable for projects requiring advanced QR code applications beyond basic functionality.

Jacob Mellor, Chief Technology Officer @ Team Iron
Chief Technology Officer

Jacob Mellor is Chief Technology Officer at Iron Software and a visionary engineer pioneering C# PDF technology. As the original developer behind Iron Software's core codebase, he has shaped the company's product architecture since its inception, transforming it alongside CEO Cameron Rimington into a 50+ person company serving NASA, Tesla, and global government agencies.

...
Read More

Ready to Get Started?

Nuget Downloads 2,422,100Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronBarCode"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronBarCode to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronBarCode.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required