How to Print a QR Code in C#
Print QR codes in C# by generating them with IronQR, converting to PDF using IronPDF, and printing with IronPrint library - a complete solution for bridging physical and digital interactions through programmable QR code printing.
QR codes, or Quick Response codes, have become ubiquitous in our digital age. They store information in a matrix of black squares on a white background and can be scanned using a smartphone or dedicated QR code reader. These QR codes/barcodes using .NET barcode DLL are used for various purposes, including product labeling, mobile payments, and marketing materials. Printing QR codes is crucial for integrating physical and digital interactions seamlessly.
In this article, we're going to first generate a QR code in C# using IronQR, the QR code generator library, then convert it to PDF using IronPDF, and finally print the pixel-perfect document with a QR code image using the C# IronPrint library.
How to Print a QR Code in C#?
- Create a Visual Studio Project
- Install IronQR, IronPDF, and IronPrint libraries
- Create a QR Code using
QrWriter.Write() method - Save the generated QR Code as an image using the
SaveAsmethod - Create a PDF document using IronPDF's
ImageToPdfConverter - Adjust
PrinterSettingsusing IronPrint - Print using IronPrint's Printer.Print() method
What Is IronPrint and Why Use It for C# Printing?
IronPrint, developed by Iron Software, is a powerful print library for .NET, offering a versatile set of tools for handling printing tasks in C#. It supports a wide range of environments, including Windows, macOS, Android, and iOS. This cross-platform capability makes it ideal for startups that need flexibility as they scale. The library's features include everything from basic document printing to advanced print control options, making it a comprehensive solution for any printing needs.
In this article, we'll explore how IronPrint, in conjunction with IronQR and IronPDF, can be leveraged to create QR codes, convert, and print QR codes in a C# console application. This combination of libraries provides a complete end-to-end solution that's both cost-effective and quick to implement - perfect for MVP development.
What Key Features Does IronPrint Offer?
IronPrint distinguishes itself with dedicated classes and methods tailored for print-related functionalities. Key features include:
- Comprehensive Print Settings: Customize paper size, orientation, DPI, copies, printer name, margins, and grayscale options. Apply custom settings to match your requirements.
- Versatile Printing with Printer Class: The Printer class provides methods for printing various file types, including images and PDFs.
- Cross-Platform Support: Works across multiple platforms, from web apps to mobile solutions.
- Printer Information Retrieval: Get printer information and manage local printers efficiently across devices.
What Prerequisites Do I Need Before Starting?
Before diving into the steps of creating a console application in C# to print QR codes, ensure you have the following prerequisites:
- Visual Studio: Install Microsoft Visual Studio, a powerful integrated development environment for C#. You can download it from its official website.
- IronQR Library: Essential for generating QR codes. Install via NuGet Console or from the official IronQR NuGet website.
- IronPDF Library: IronPDF converts generated QR code images to PDF. Install using the same NuGet method.
- IronPrint Library: Install IronPrint to enable seamless printing. Check licensing options for your startup's needs.
How Do I Create a C# Console Application in Visual Studio?
Follow these steps to set up a C# console application in Visual Studio:
- Open Visual Studio and create a new C# Console Application
Configure the Project as follows and then click "Next"

- Next, for additional information, choose the .NET Framework and click "Create".
How Do I Install Necessary Libraries via NuGet Package Manager?
Follow the steps to install the necessary libraries:
- Open NuGet Package Manager Console or NuGet Package Manager for Solutions using the Tools menu or Solution Explorer in the Visual Studio project.
Install IronQR QR Code library:
- Using the NuGet Package Manager Console, execute the following command:
Install-Package IronPrint
- Using the Manage NuGet Packages for Solutions: In the Browse tab of NuGet, search for "IronQR", QR Code library and click Install.

Install IronPDF PDF Library:
Using the NuGet Package Manager Console, enter the following command:
Install-Package IronPrint
- Using the Manage NuGet Packages for Solutions: In the Browse tab of NuGet, search for the "IronPDF" library and click Install.

Install IronPrint Printing Library:
Using the NuGet Package Manager Console, add the following command:
Install-Package IronPrint
- Using the Manage NuGet Packages for Solutions: In the Browse tab of NuGet, search for the "IronPrint" library and click Install.

What Are the Steps to Create, Convert, and Print QR Codes?
Let's break down the process of creating QR codes, converting QR codes to PDF, and finally printing the output of the QR code generator in a step-by-step procedure using IronQR, IronPDF, and IronPrint. This workflow is designed to be implemented quickly, perfect for startup environments where time-to-market is critical. The entire process can be set up and running in under 30 minutes, allowing you to integrate QR code printing into your MVP rapidly.
How Do I Implement the Complete QR Code Printing Process?
Step 1: Reference Libraries
In the Program.cs file at the top, we'll include references to the required libraries. This ensures that the libraries are installed and ready to be used. These imports provide access to all the necessary functionality for QR generation, PDF conversion, and printing operations.
// Reference to libraries
using IronPrint; // Library for printing functionalities
using IronPdf; // Library for PDF handling
using IronQr; // Library for QR code generation
using IronSoftware.Drawing; // Library for image processing// Reference to libraries
using IronPrint; // Library for printing functionalities
using IronPdf; // Library for PDF handling
using IronQr; // Library for QR code generation
using IronSoftware.Drawing; // Library for image processingStep 2: Create a QR Code Using IronQR
In this step, we'll first generate a QR code using IronQR and then save it as an image, as shown in the following code example. IronQR makes this process incredibly straightforward with just a few lines of code:
// Code to create a QR code using IronQR
QrCode myQr = QrWriter.Write("Hello IronPrint!"); // Generate a QR code with the message
AnyBitmap qrImage = myQr.Save(); // Save QR code as an image
qrImage.SaveAs("assets/qr.png"); // Save the png image file to the "assets" folder
// For more advanced QR codes, you can include URLs, contact info, or WiFi credentials
// Example: QrCode urlQr = QrWriter.Write("___PROTECTED_URL_52___");
// Example: QrCode wifiQr = QrWriter.Write("WIFI:T:WPA;S:NetworkName;P:Password;;");// Code to create a QR code using IronQR
QrCode myQr = QrWriter.Write("Hello IronPrint!"); // Generate a QR code with the message
AnyBitmap qrImage = myQr.Save(); // Save QR code as an image
qrImage.SaveAs("assets/qr.png"); // Save the png image file to the "assets" folder
// For more advanced QR codes, you can include URLs, contact info, or WiFi credentials
// Example: QrCode urlQr = QrWriter.Write("___PROTECTED_URL_52___");
// Example: QrCode wifiQr = QrWriter.Write("WIFI:T:WPA;S:NetworkName;P:Password;;");In this code snippet:
- A QR code is generated with the message "Hello IronPrint!" using
QrWriter. - The QR code is saved as an
AnyBitmapfile. - The image is saved to "assets" folder as "
qr.png". - You can customize this for your company URL or product info.
Here is the QR code output:

For startups looking to implement QR codes for various use cases like inventory tracking, customer engagement, or payment processing, IronQR provides extensive customization options. You can adjust error correction levels, size, and even add logos to your QR codes.
Step 3: Convert QR Image to PDF Using IronPDF
Next, we'll convert the QR code image to a PDF using IronPDF. PDFs preserve the format of the document and are suitable for sharing and printing. Here, each image file will be placed on a separate PDF file page. This approach is particularly useful when you need to generate multiple QR codes for batch printing:
// Code to convert QR Image to PDF using IronPDF
var imageFiles = Directory.EnumerateFiles("assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".png")); // Reading QR codes image files
// Convert the QR code images to a PDF and save it
ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs("assets/composite.pdf");
// For batch processing multiple QR codes
// You can also add custom headers, footers, or watermarks to your PDFs
// This is useful for branding or adding tracking information// Code to convert QR Image to PDF using IronPDF
var imageFiles = Directory.EnumerateFiles("assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".png")); // Reading QR codes image files
// Convert the QR code images to a PDF and save it
ImageToPdfConverter.ImageToPdf(imageFiles).SaveAs("assets/composite.pdf");
// For batch processing multiple QR codes
// You can also add custom headers, footers, or watermarks to your PDFs
// This is useful for branding or adding tracking informationIn this code snippet:
- Enumerates image files in "assets" folder with ".jpg" or ".png" extensions.
- Uses
ImageToPdfConverter.ImageToPdf() to convert images to PDF. - Saves the result as "
composite.pdf". - Efficient for batch processing multiple QR codes.
Here is the output:

Step 4: Print PDF Using IronPrint
Finally, we'll use IronPrint - a versatile printing library to print the generated PDF with printer settings. IronPrint provides extensive control over the printing process, allowing you to configure everything from paper size to margins. You can explore the print settings tutorial for more advanced configurations:
// Code for Printing using IronPrint
// Get available printer names
List<string> printerNames = Printer.GetPrinterNames();
// Create print settings object
PrintSettings printerSettings = new PrintSettings();
foreach(string printerName in printerNames)
{
// Set desired printer name
if(printerName.Equals("Microsoft Print to PDF"))
printerSettings.PrinterName = printerName;
}
// Configure print settings
printerSettings.PaperSize = PaperSize.A4; // Set paper size
Margins margins = new Margins(30, 10); // Set paper margins
printerSettings.PaperMargins = margins; // Apply margins
// Additional settings for production environments
printerSettings.Grayscale = false; // Color printing for better QR code contrast
printerSettings.NumberOfCopies = 1; // Set number of copies
printerSettings.Dpi = 300; // High DPI for clear QR codes
// Print the PDF
Printer.Print("assets/composite.pdf", printerSettings); // Print the PDF
// For interactive printing with user dialog
// Printer.ShowPrintDialog("assets/composite.pdf", printerSettings);// Code for Printing using IronPrint
// Get available printer names
List<string> printerNames = Printer.GetPrinterNames();
// Create print settings object
PrintSettings printerSettings = new PrintSettings();
foreach(string printerName in printerNames)
{
// Set desired printer name
if(printerName.Equals("Microsoft Print to PDF"))
printerSettings.PrinterName = printerName;
}
// Configure print settings
printerSettings.PaperSize = PaperSize.A4; // Set paper size
Margins margins = new Margins(30, 10); // Set paper margins
printerSettings.PaperMargins = margins; // Apply margins
// Additional settings for production environments
printerSettings.Grayscale = false; // Color printing for better QR code contrast
printerSettings.NumberOfCopies = 1; // Set number of copies
printerSettings.Dpi = 300; // High DPI for clear QR codes
// Print the PDF
Printer.Print("assets/composite.pdf", printerSettings); // Print the PDF
// For interactive printing with user dialog
// Printer.ShowPrintDialog("assets/composite.pdf", printerSettings);In this source code snippet:
- Fetches printer names using Printer.
GetPrinterNames(). - Sets printer name to "Microsoft Print to PDF" for demonstration.
- Configures A4 paper size and 30/10 margins.
- Sets DPI to 300 for clear QR codes.
- Prints using Printer.Print() with configured settings.
Here is the output of the print file. This shows how the image will be printed:

Printing to a physical printer is much easier with IronPrint. To get more control while printing, you can use ShowPrintDialog() method as demonstrated in the print with dialog example. For more information on how to print efficiently, please visit this documentation page or check out the comprehensive print document tutorial.
Why Choose IronPrint Over Other Printing Solutions in C#?
IronPrint is specifically designed as a powerful print library for .NET applications. Unlike IronPDF, which primarily focuses on PDF-related tasks, and Microsoft printing, which is a general-purpose printing mechanism, IronPrint provides dedicated classes and methods tailored for fine-grained control over the printing process. The API Reference provides comprehensive documentation of all available classes and methods.
With IronPrint, developers can leverage advanced features that streamline the development process and reduce time-to-market - crucial factors for startup success. The library's architecture handles everything from simple document printing to complex batch operations with minimal code.
Why Does Asynchronous Printing Matter?
IronPrint provides asynchronous functions, preventing print operations from blocking threads and enhancing performance. This is particularly important for web applications where responsiveness is critical. The ASP.NET Web App Framework guide shows how to implement async printing in web environments.
How Does Versatile Printing Benefit My Application?
The dedicated Printer class in IronPrint allows for versatile printing of various file types, offering flexibility beyond standard printing. You can print your documents in multiple formats without needing separate libraries for each file type.
Which Platforms Does IronPrint Support?
IronPrint supports Windows, Android, iOS, and macOS, making it suitable for diverse application environments. This cross-platform capability means you can build once and deploy everywhere, significantly reducing development costs.
What Print Settings Can I Customize?
Developers can finely control paper size, orientation, DPI, copies, and more through the PrintSettings class. The print settings example demonstrates all customization options.
What Are the Key Takeaways for QR Code Printing in C#?
The combination of IronPrint, IronQR, and IronPDF provides a robust solution for creating, converting, and printing QR codes in C#. The advantages of asynchronous printing, versatile printing options, and cross-platform support make IronPrint a valuable tool for developers. By following the detailed steps outlined in this guide, you can generate QR code barcodes and seamlessly integrate their printing into your C# applications, bridging the gap between physical and digital interactions.
For startups looking to implement QR code solutions quickly, this technology stack offers several advantages:
- Rapid Implementation: Get your QR code printing up and running in under an hour
- Cost-Effective: Start with free trial and scale with flexible licensing
- Production-Ready: Built-in error handling and high-performance architecture
- Future-Proof: Regular updates and excellent support ensure long-term viability
IronPrint offers a free-trial starts from $799, making it accessible for startups to evaluate before committing. You can explore different licensing options including extensions and upgrades as your business grows. Download the library from here and give it a try.
For additional support, check out the troubleshooting guides or learn how to properly configure license keys in your projects. If you're working with web applications, the guide on setting license key in Web.config will help you get started quickly.
To stay updated with the latest features and improvements, check the changelog regularly. The IronPrint team continuously adds new capabilities based on user feedback, ensuring the library evolves with your needs.
Frequently Asked Questions
How do QR codes work in digital applications?
QR codes store information in a matrix of black squares on a white background, which can be scanned using a smartphone or dedicated QR code reader. They are widely used for product labeling, mobile payments, and marketing materials.
How can I generate a QR code in a .NET application?
To generate a QR code in a .NET application, use the IronQR library. The QrWriter.Write() method allows you to create a QR code, which can then be saved as an image for further processing.
What steps are involved in printing QR codes using C#?
The process involves generating the QR code with IronQR, converting it to a PDF using IronPDF, and then printing it with IronPrint. This sequence ensures a high-quality output suitable for various applications.
What makes IronPrint a versatile choice for .NET print tasks?
IronPrint offers extensive features such as asynchronous printing, comprehensive print settings customization, and cross-platform support, making it a versatile choice for .NET print tasks.
Which platforms are supported by IronPrint for printing tasks?
IronPrint supports printing on multiple platforms, including Windows, macOS, Android, and iOS, providing flexibility for developers working in diverse environments.
How can I install IronQR, IronPDF, and IronPrint libraries in Visual Studio?
Install these libraries using the NuGet Package Manager in Visual Studio. Use the 'Install-Package' command in the NuGet Console to add each library to your project.
What advantages does IronPrint offer over traditional Microsoft printing?
IronPrint offers advantages such as asynchronous printing, versatile file type support, and customizable print settings, providing a robust solution for integrating QR code printing into C# applications.
How do I convert a QR code image to a PDF in C#?
You can convert a QR code image to a PDF in C# using the IronPDF library. Use the RenderHtmlAsPdf method to include the QR code image within a PDF document.
What are the prerequisites for setting up QR code printing in C#?
Ensure you have Visual Studio installed, along with the IronQR, IronPDF, and IronPrint libraries. These can be installed via the NuGet Package Manager in Visual Studio.









