我使用同步组件的Word到PDF转换,然后应用签名从PDF.pfx文件提供的同步融合。下面是代码参考:
打开PDF文档并应用签名:
PdfLoadedDocument document = new PdfLoadedDocument("WordtoPDF8.pdf");
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Creates a signature field.
PdfSignatureField signatureField = new PdfSignatureField(page, "SignatureField");
signatureField.Bounds = new RectangleF(0, 0, 100, 100);
signatureField.Signature = new PdfSignature(document, page, new PdfCertificate(@"C:\Users\someUser\AppData\Local\Syncfusion\EssentialStudio\14.4.0.15\Common\Data\PDF\PDF.pfx", "syncfusion"), "SignatureField");
signatureField.Signature.Reason = "I am author of this document";
//Adds the field.
document.Form.Fields.Add(signatureField);
//Saves the certified PDF document.
document.Save();
//Closes the document
document.Close(true);现在打开文档并使用以下代码读取签名:
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("WordtoPDF8.pdf");
//Gets the page of the document
PdfLoadedPage page1 = loadedDocument.Pages[0] as PdfLoadedPage;
//Gets the signature field from the PDF document
PdfLoadedField field = null;;
loadedDocument.Form.Fields.TryGetField("syncfusion",out field);
PdfLoadedSignatureField field2 = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
//Get PDF Certificate instance from signature field
PdfCertificate certificate2 = field2.Signature.Certificate;
//Get the certificate details
string subjectName = certificate2.SubjectName;
string issuerName = certificate2.IssuerName;我得到的问题是,当我得到certificate2时,它是空的。我不知道问题出在哪里。我们将非常感谢您的帮助。
发布于 2018-12-19 01:35:27
最近提供了从现有签名PDF文档中检索证书详细信息的支持,即从v16.4.0.42开始。请参考下面的链接下载最新的essential studio。
请检查以上最新版本以解决PdfCertificate空问题。注意:我在Syncfusion工作。
你好,迪利·巴布。
https://stackoverflow.com/questions/53810540
复制相似问题