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

直接將QR碼蓋印在現有的PDF頁面上,嵌入可掃描的資訊而不需重新結構化文件。 IronQR通過三個步驟處理此問題:用DrawBitmap,以精準控制蓋印的尺寸。

將QR碼蓋印到PDF的三步指南

  • AnyBitmap qrBitmap = QrWriter.Write("hello world").Save();
  • PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
  • pdf.DrawBitmap(qrBitmap, pageIndex: 0, x: 505, y: 20, desiredWidth: 70, desiredHeight: 70, pixelFormat: PixelFormat.Format32bppArgb, ignorePageRotation: false);

程式碼說明

AnyBitmap返回。 位圖被傳遞給載入的DrawBitmapy值從左上角以PDF點為單位(A4頁面為595 × 842點),而height精確設置蓋印尺寸——此處70 × 70點將一個緊湊的QR碼放在右上角。 調用pdf.SaveAs()來寫入結果。

常見用例包括在發票上嵌入付款連結,為法律文件新增驗證碼,以及在活動票證上放置追蹤ID。 為平衡尺寸和資料,配置一個不同錯誤更正級別的QrWriter.Write

探索如何使用IronQR將QR碼蓋印到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天試用金鑰
無需信用卡或帳戶建立