IRONSOFTWAREHOME
将QR码盖到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");
Imports IronQr
Imports IronPdf
Imports IronSoftware.Drawing

' Generate QR code and save as bitmap
Dim qrBitmap As AnyBitmap = QrWriter.Write("hello world").Save()

' Load an existing PDF document
Dim pdf As PdfDocument = 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
将QR码盖到PDF

将QR码盖到PDF

将二维码直接印在现有 PDF 页面上,可在不改变文档结构的情况下嵌入可扫描信息。 IronQR通过三个步骤处理此事:创建一个QrWriter,使用Write生成二维码,然后调用StampToExistingPdfPage,传入 PDF 路径以及用于在所选页面上定位印章的xy坐标。

将二维码嵌入 PDF 的 3 步指南

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

代码解释

QrWriter.Write生成二维码并返回一个QrCode。 在该QrCode上调用StampToExistingPdfPage会将其直接印到源 PDF 上,方法接受 PDF 路径、xy位置、从零开始的pageIndex以及 PDF 密码(此处为空)。 xy的值决定印章在页面上的位置——505, 20将其放在靠近右上角的位置。

常见应用场景包括在发票中嵌入支付链接、在法律文件中添加验证码,以及在活动门票上添加追踪 ID。 为了权衡尺寸与数据量,可以配置一个具有不同纠错级别的QrOptions对象,并将其传递给QrWriter.Write

了解如何使用 IronQR 将二维码嵌入 PDF 页面。

准备开始了吗?

Nuget Downloads 74,386版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户