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 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布