我想使用IronPdf库生成一个带有签名图像的数字签名pdf,但我遇到了以下问题:
虽然pdf是数字签名的,但签名的图像似乎没有呈现/出现在生成的pdf中。
上面的代码(我正在控制台应用程序中测试(基于:https://ironpdf.com/docs/questions/signing/(第三种情况(
// Step 1. Create a PDF
ChromePdfRenderer Renderer = new ChromePdfRenderer();
using PdfDocument doc = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>");
// Step 2. Create a Signature.
// You may create a .pfx or .p12 PDF signing certificate using Adobe Acrobat Reader.
// Read: https://helpx.adobe.com/acrobat/using/digital-ids.html
var Signature = new IronPdf.Signing.PdfSignature("ChristosAsvestopoulos.pfx", "123abc!");
// Step 3. Optional signing options and a handwritten Signature graphic
Signature.SigningContact = "support@ironsoftware.com";
Signature.SigningLocation = "Chicago, USA";
Signature.SigningReason = "To show how to sign a PDF";
Signature.LoadSignatureImageFromFile("handwriting.png");
//Step 4. Sign the PDF with the PdfSignature. Multiple signing certificates may be used
doc.SignPdfWithDigitalSignature(Signature);
//Step 5. The PDF is not signed until saved to file, steam or byte array.
doc.SaveAs("signed.pdf");
注:
.pfx文件是按照以下方式创建的:https://helpx.adobe.com/acrobat/using/digital-ids.html
IronPdf版本:2022.8.7894
操作系统:Windows 10企业版
应用程序的框架:。NET Core 3.1
对于handwriting.png
文件,我也尝试过(但没有成功(:https://ironpdf.com/troubleshooting/digital-signatures/
我已经将这篇文章链接到开发票证上,因此我们将在未来的更新中解决此问题后联系并通知您。
您可以向发送后续消息developers@ironsfotware.com持54677号票据。
IronPdf版本2023.3.2中已修复该问题。
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
pdf.SaveAs("signed.pdf");
// Create PdfSignature object
var sig = new PdfSignature("IronSoftware.pfx", "123456");
// Add image
sig.SignatureImage = new PdfSignatureImage("IronSoftware.png", 0, new CropRectangle(0, 600, 100, 100));
// Sign and save PDF document
sig.SignPdfFile("signed.pdf");
有关详细信息,请访问"对PDF文档进行数字签名"。