在IronPDF中應用數位簽章

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

數位簽章是一種密碼學方法,可以使用IronPDF程式庫新增到現有的PDF文件中。 這包括新增單一多重簽章與漸進式儲存簽章。

支援的數位簽章憑證

IronPDF支援Windows格式的.p12數位簽章憑證。 這些憑證符合X509Certificate2標準。 您可以通過檢查數位簽章憑證的檔案擴展名來驗證其格式。

如果您沒有所需格式的憑證,請參照此文件來建立新的X509Certificate2標準憑證。 然後可以通過IronPDF將生成的憑證應用於PDF文件。

請注意IronPDF僅支援X509KeyStorageFlags.Exportable。 某些憑證的KeyStorageFlags預設為可匯出。 嘗試使用不同的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擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

準備開始了嗎?
Nuget 下載 20,296,129 | 版本: 2026.7 剛剛發布
Still Scrolling Icon

還在捲動嗎?

想快速獲得證明嗎? PM > Install-Package IronPdf
執行範例 看您的HTML變成PDF。