在 IronPDF 中应用数字签名
数字签名是一种可以使用 IronPDF 库添加到现有 PDF 文档的加密方法。 这包括添加单个和具有增量保存的多个签名。
支持的数字签名证书
IronPDF支持在Windows上的.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 提交工程支持请求。

