在IronPDF中應用數位簽名

This article was translated from English: Does it need improvement?
Translated
View the article in English

數位簽章是一種加密方法,可以使用IronPDF庫將其新增至現有的 PDF 文件中。 這包括添加單一多個簽名,以及增量節省簽名。

支援的數位簽章證書

IronPDF支援 Windows 系統下 .pfx 格式的數位簽章憑證和 MacOS 系統下 .p12 格式的數位簽章憑證。 這些符合 X509Certificate2 標準。 您可以透過檢查檔案副檔名來驗證現有數位簽章憑證的格式。

如果您沒有所需格式的證書,請參考此文件建立新的 X509Certificate2 標準證書。 然後可以使用IronPDF將產生的憑證套用到 PDF 文件中。

請注意IronPDF只支援 X509KeyStorageFlags.Exportable。 某些證書預設為可匯出。 嘗試使用不同的 KeyStorageFlags 將導致拋出異常。 )}]

帶有圖像的簽名

可以在 PDF 文件中添加圖像,以直觀地表明該文件已進行數位簽章。 使用IronPDF可以透過以下程式碼片段實現此目的:

// Create a PdfSignature object by specifying the certificate file (.pfx) and its password
var sig = new PdfSignature("IronSoftware.pfx", "123456");

// Set the signature image which includes the image path, page number, and its position in the document
sig.SignatureImage = new PdfSignatureImage("IronSoftware.png", 0, new Rectangle(0, 600, 100, 100));
// Create a PdfSignature object by specifying the certificate file (.pfx) and its password
var sig = new PdfSignature("IronSoftware.pfx", "123456");

// Set the signature image which includes the image path, page number, and its position in the document
sig.SignatureImage = new PdfSignatureImage("IronSoftware.png", 0, new Rectangle(0, 600, 100, 100));
$vbLabelText   $csharpLabel

確保在專案中將影像檔案屬性設定為 "CopyToOutputDirectory=always",以便在應用程式簽名後可以在 PDF 文件中找到並渲染該影像。

要了解有關透過IronPDF應用數位簽章的更多信息,請查看"對 PDF 文件進行數位簽章"

如需工程支持,請參閱如何為IronPDF提出工程支持請求

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 17,803,474 | 版本: 2026.3 剛剛發布
Still Scrolling Icon

還在滾動嗎?

想快速取得證據? PM > Install-Package IronPdf
運行範例看著你的HTML程式碼變成PDF檔。