Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
Quick Response codes, known as QR codes, are two-dimensional barcodes capable of storing various information, including URLs, contact details, or plain text. They are widely used in marketing, payment systems, inventory management, printing, and more. As their popularity grows, developers increasingly need to handle QR codes within applications, such as reading and embedding them into documents like PDFs as well as ways to generate QR code and QR code generation.
In this article, I’ll show you how easy it is to create and convert a QR Code image to PDF using the IronQR and IronPDF libraries.
IronQR is an easy-to-use C# library by Iron Software that allows developers to generate static QR codes, style, and read QR codes in .NET applications. Its simplicity and robust features make it an ideal tool for integrating QR code functionality into desktop, web, and mobile apps. One of its key strengths is the ability to handle QR codes across a wide range of platforms, including Windows, Linux, macOS, Android, iOS, and cloud environments like Azure and AWS.
The IronQR library provides a robust solution for generating QR codes, allowing developers to create static and dynamic QR codes for various applications easily. With its advanced features, IronQR facilitates reading QR codes and integrates seamlessly with PDF documents, enabling users to generate, print, and embed QR codes directly into their PDFs.
IronQR offers a range of features that prioritize accuracy, speed, and ease of use:
To learn more about IronQR and its exciting features, please follow this documentation page.
To begin, let's create a new project in Visual Studio:
Open Visual Studio and click on Create a new project.
Select Console App (.NET C#) project type.
Choose a name for your project (e.g., QRCodeToPDF) and set the location where it should be saved.
In Additional Information, select the latest version of .NET Framework. IronPDF supports the latest version of .NET.
To work with IronQR and IronPDF, you need to download and install the packages using the NuGet Package Manager:
In the Browse tab, search for IronQR.
Similarly, search for IronPDF and install it.
To convert a QR code image into a PDF, we'll first need a QR code image. You can use any QR code generator library or online tool to create a QR code. Iron Software provides a dedicated QR code library named "IronQR" to create QR codes, and I'm going to use it here to generate a simple QR code.
The following code example will allow us to create a QR code with the text Hello World:
using IronQr;
using IronSoftware.Drawing;
License.LicenseKey = “YOUR-LICENSE-KEY-HERE”;
// Create a QR Code object
QrCode myQr = QrWriter.Write("hello world");
// Save QR Code as a Bitmap
AnyBitmap qrImage = myQr.Save();
// Save QR Code Bitmap as File
qrImage.SaveAs("qr.png");
using IronQr;
using IronSoftware.Drawing;
License.LicenseKey = “YOUR-LICENSE-KEY-HERE”;
// Create a QR Code object
QrCode myQr = QrWriter.Write("hello world");
// Save QR Code as a Bitmap
AnyBitmap qrImage = myQr.Save();
// Save QR Code Bitmap as File
qrImage.SaveAs("qr.png");
Imports IronQr
Imports IronSoftware.Drawing
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'License.LicenseKey = "YOUR-LICENSE-KEY-HERE”; QrCode myQr = QrWriter.Write("hello world"); AnyBitmap qrImage = myQr.Save(); qrImage.SaveAs("qr.png");
After running the application, we get our QR code as follows:
We will load this QR Code image and use the ImageToPdfConverter class provided by IronPDF.
IronPDF is a robust .NET C# library from IronSoftware that easily creates, manipulates, and converts PDF documents in .NET applications. With IronPDF, developers can easily embed images (including QR codes) into a PDF document template, making it perfect for tasks like converting QR code images into a document-ready PDF.
IronPDF provides HTML to PDF conversion, which allows developers to directly embed QR code images in an HTML template and then generate PDF documents seamlessly. The embedded QR code formatting is preserved in the document, allowing error-free scanning of the QR codes.
IronPDF offers a wide range of PDF manipulation tools, including:
To learn more about IronPDF's exciting features, please follow this documentation page.
Now, with everything set up perfectly, the following code example will help you convert a QR code image to a PDF using IronPDF:
using IronPdf;
using System.IO;
using System.Linq;
License.LicenseKey = “YOUR-LICENSE-KEY-HERE”;
var qrImagePath = "assets/sample_qr_code.png";
// To ensure that the image file exists before proceeding
if (File.Exists(qrImagePath))
{
// Convert the image to a PDF and save it
ImageToPdfConverter.ImageToPdf(new[] { qrImagePath }).SaveAs("QRCodeImageToPDF.pdf");
Console.WriteLine("QR Code image has been successfully converted to a PDF.");
}
else
{
Console.WriteLine("QR Code image not found. Please check the file path.");
}
using IronPdf;
using System.IO;
using System.Linq;
License.LicenseKey = “YOUR-LICENSE-KEY-HERE”;
var qrImagePath = "assets/sample_qr_code.png";
// To ensure that the image file exists before proceeding
if (File.Exists(qrImagePath))
{
// Convert the image to a PDF and save it
ImageToPdfConverter.ImageToPdf(new[] { qrImagePath }).SaveAs("QRCodeImageToPDF.pdf");
Console.WriteLine("QR Code image has been successfully converted to a PDF.");
}
else
{
Console.WriteLine("QR Code image not found. Please check the file path.");
}
Imports IronPdf
Imports System.IO
Imports System.Linq
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'License.LicenseKey = "YOUR-LICENSE-KEY-HERE”; var qrImagePath = "assets/sample_qr_code.png"; if (File.Exists(qrImagePath)) { ImageToPdfConverter.ImageToPdf(new[] { qrImagePath }).SaveAs("QRCodeImageToPDF.pdf"); Console.WriteLine("QR Code image has been successfully converted @to a PDF."); } else { Console.WriteLine("QR Code image @not found.Please check the file path."); }
To convert multiple QR code images into a single PDF, please visit this Images to PDF page. For more code samples, please visit this code example page here.
Now that the code is in place, it's time to run the application and see the conversion in action. Follow these steps:
You should now have a PDF containing your QR code image, which can be shared, printed, or archived. Here is the output PDF with the QR code image we used:
Using IronQR and IronPDF, creating and converting a QR code image to a PDF is simple and efficient. By following the steps outlined above, you can easily create a QR code image, convert it, and save it as a PDF in just a few lines of code. Whether for business or personal use, this approach ensures that your QR code is document-ready in PDF format and can be shared over the internet without any data or pixel loss.
IronPDF provides a free trial so you can explore its features and capabilities for yourself. For those ready to unlock the full potential of the library, licenses start at $749, offering comprehensive access to all functionalities. Don't miss the opportunity to enhance your PDF generation—try IronPDF today by downloading it!