在IronPDF中應用數位簽名
數位簽章是一種加密方法,可以使用IronPDF庫將其新增至現有的 PDF 文件中。 這包括添加單一和多個簽名,以及增量節省簽名。
支援的數位簽章證書
IronPDF支援 Windows 系統下 .pfx 格式的數位簽章憑證和 MacOS 系統下 .p12 格式的數位簽章憑證。 這些符合 X509Certificate2 標準。 您可以透過檢查檔案副檔名來驗證現有數位簽章憑證的格式。
如果您沒有所需格式的證書,請參考此文件建立新的 X509Certificate2 標準證書。 然後可以使用IronPDF將產生的憑證套用到 PDF 文件中。
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));
' 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))
確保在專案中將影像檔案屬性設定為 "CopyToOutputDirectory=always",以便在應用程式簽名後可以在 PDF 文件中找到並渲染該影像。
要了解有關透過IronPDF應用數位簽章的更多信息,請查看"對 PDF 文件進行數位簽章" 。
如需工程支持,請參閱如何為IronPDF提出工程支持請求。

