Applying Digital Signatures in IronPDF

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

數位簽章是一種可以使用 IronPDF 庫添加到現有 PDF 文件中的加密方法。 This includes adding single and multiple signatures with incremental savings signatures.

支援的數位簽章證書

IronPDF 支援 Windows 使用 .pfx 格式和 MacOS 使用 .p12 格式的數位簽章證書。 這些證書符合 X509Certificate2 標準。 您可以透過檢查其文件擴展名來驗證您現有的數位簽章證書的格式。

如果您沒有符合要求格式的證書,請參考此文件來建立新的 X509Certificate2 標準證書。 生成的證書然後可以通過 IronPDF 使用並應用於 PDF 文件。

[{i:(IronPDF 僅支援 X509KeyStorageFlags.Exportable。 某些證書的 KeyStorageFlags 默認設置為 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));
' Create a PdfSignature object by specifying the certificate file (.pfx) and its password
Dim 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 下載 16,154,058 | 版本: 2025.11 剛剛發布