Stamp QR Code to PDF
using IronQr;
using IronPdf;
using IronSoftware.Drawing;

// Generate QR code and save as bitmap
AnyBitmap qrBitmap = QrWriter.Write("hello world").Save();

// Load an existing PDF document
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");

// Stamp the QR code onto the first page at position x=505, y=20 (top-right corner)
pdf.DrawBitmap(qrBitmap, PageIndex: 0, X: 505, Y: 20, DesiredWidth: 70, DesiredHeight: 70, PixelFormat: PixelFormat.Format32bppArgb, IgnorePageRotation: false);

// Save the modified PDF
pdf.SaveAs("output.pdf");
NuGet Download
PM > Install-Package IronQR
Stamp QR Code to PDF

Stamp QR Code to PDF

Stamping a QR code directly onto an existing PDF page embeds scannable information without restructuring the document. IronQR handles this in three steps: create a QrWriter, generate the QR code with Write, then call StampToExistingPdfPage with the PDF path and the x and y coordinates that position the stamp on the chosen page.

3-step guide for stamping a QR code into a PDF

  • QrWriter writer = new QrWriter();
  • QrCode myQr = writer.Write("hello world");
  • myQr.StampToExistingPdfPage("sample.pdf", 505, 20, 0, "");

Code Explanation

QrWriter.Write generates the QR code and returns a QrCode. Calling StampToExistingPdfPage on that QrCode stamps it directly onto the source PDF, taking the PDF path, the x and y position, the zero-based pageIndex, and the PDF password (empty here). The x and y values position the stamp on the page - 505, 20 places it near the top-right corner.

Common use cases include embedding payment links on invoices, adding verification codes to legal documents, and placing tracking IDs on event tickets. For size-to-data tradeoffs, configure a QrOptions object with a different error correction level and pass it to QrWriter.Write.

Explore How to Stamp QR Codes into PDF Pages with IronQR.

Ready to Get Started?

Nuget Downloads 80,612Version:2026.11just released