在 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預設為 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擁有卡爾頓大學電腦科學學士學位,專長於前端開發,精通Node.js、TypeScript、JavaScript和React。他熱衷於打造直覺美觀的使用者介面,喜歡使用現代框架,並擅長撰寫結構清晰、視覺效果出色的使用者手冊。

除了開發工作之外,柯蒂斯對物聯網 (IoT) 也抱有濃厚的興趣,致力於探索硬體和軟體整合的創新方法。閒暇時,他喜歡玩遊戲和製作 Discord 機器人,將他對科技的熱愛與創造力結合。

準備好開始了嗎?
Nuget 下載 17,012,929 | 版本: 2025.12 剛剛發布