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 路径以及用于在所选页面上定位印章的x和y坐标。

将二维码嵌入 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 路径、x和y位置、从零开始的pageIndex以及 PDF 密码(此处为空)。 x和y的值决定印章在页面上的位置——505, 20将其放在靠近右上角的位置。

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

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

准备开始了吗?

Nuget Downloads 76,271版本:2026.10刚刚发布

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 IronQR
预约您的免费现场演示
Booking Badge

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

Iron Software 的客户徽标
获取您的无义务咨询
您的资料将始终保密。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
深受全球数百万工程师信赖
立即获取您的免费30 天试用密钥。
无需信用卡或创建账户
C# 用于 PDF 的 NuGet 库
通过 NuGet 安装

版本: 2026.10

PM > Install-Package IronQR
nuget.org/packages/IronQR/
  1. 在解决方案资源管理器中,右键点击引用,管理 NuGet 包
  2. 选择浏览并搜索“IronQR”
  3. 选择包并安装
C# PDF DLL
下载 DLL

版本: 2026.10

  1. 下载并解压IronQR到您的解决方案目录中的~/Libs等位置
  2. 在Visual Studio解决方案资源管理器中,右键单击引用。选择浏览,“IronQR.dll”

许可证从$999开始