Verify Pdf hasn't modified after adding signature?.
Hello,
I am using PDF component for adding digital signatures to the pdf document.
Here is how I am adding the signature
PdfLoadedDocument document = new PdfLoadedDocument("DigitalSignaturee2.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\Public\Documents\Syncfusion\ASP.NET MVC - EJ2\16.3.0.21\App_Data\PDF\PDF.pfx", "syncfusion"), "SignatureField");
signatureField.Signature.Reason = "I am author of this document";
document.Form.Fields.Add(signatureField);
document.Save();
//Closes the document
document.Close(true);
I can get the document certificate as of volume 4 release. But how can I verify that document hasn't modified after the signature was added.
Here is the code for the signature retrieval.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("DigitalSignaturee2.pdf");
//Gets the page of the document
PdfLoadedPage page1 = loadedDocument.Pages[0] as PdfLoadedPage;
PdfLoadedSignatureField field2 = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
//Get PDF Certificate instance from signature field
PdfCertificate certificate = field2.Signature.Certificate;
//Get the certificate details
string subjectName = certificate.SubjectName;
string issuerName = certificate.IssuerName;
thanks
iosman
SIGN IN To post a reply.
3 Replies
SL
Sowmiya Loganathan
Syncfusion Team
November 7, 2019 12:11 PM UTC
Hi iosman,
Thank you for contacting Syncfusion support.
We can verify whether PDF document has been modified or not by using “IsDocumentProperty” of PdfLoadedSignatureField. Please refer the below documentation link for more details,
We have checked with the provided code snippet and noticed that you have adding the signature field to PDF form after adding the signature in it. While doing this resultant PDF get changed, so we have modified the code snippet and please find the same from below,
|
//Load PDF document
PdfLoadedDocument document = new PdfLoadedDocument("DigitalSignaturee2.pdf");
//Get loaded page
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Creates a signature field
PdfSignatureField signatureField = new PdfSignatureField(page, "SignatureField");
//Add siganture
signatureField.Bounds = new RectangleF(0, 0, 100, 100);
signatureField.Signature = new PdfSignature(document, page, new PdfCertificate(@"PDF.pfx", "syn
signatureField.Signature.Reason = "I am author of this document";
//Save the document
document.Save();
//Closes the document
document.Close(true);
//Load the documet
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("DigitalSignaturee2.pdf");
//Gets the page of the document
PdfLoadedPage page1 = loadedDocument.Pages[0] as PdfLoadedPage;
//Gets the first signature field of the PDF document.
PdfLoadedSignatureField field2 = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;
//Validate signature and get the validation result
PdfSignatureValidationResult result = field2.ValidateSignature();
//Get value whether document is modified or not
bool isDocumentModified = result.IsDocumentModified; |
Sample Link: https://www.syncfusion.com/downloads/support/forum/148883/ze/DigitalSignatureSample1551523105
Please try the above sample in your end and let us know the result.
Regards,
Sowmiya Loganathan
Hello,I am using PDF component for adding digital signatures to the pdf document.Here is how I am adding the signaturePdfLoadedDocument document = new PdfLoadedDocument("DigitalSignaturee2.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\Public\Documents\Syncfusion\ASP.NET MVC - EJ2\16.3.0.21\App_Data\PDF\PDF.pfx", "syncfusion"), "SignatureField");signatureField.Signature.Reason = "I am author of this document";document.Form.Fields.Add(signatureField);document.Save();//Closes the documentdocument.Close(true);I can get the document certificate as of volume 4 release. But how can I verify that document hasn't modified after the signature was added.Here is the code for the signature retrieval.PdfLoadedDocument loadedDocument = new PdfLoadedDocument("DigitalSignaturee2.pdf");//Gets the page of the documentPdfLoadedPage page1 = loadedDocument.Pages[0] as PdfLoadedPage;PdfLoadedSignatureField field2 = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;//Get PDF Certificate instance from signature fieldPdfCertificate certificate = field2.Signature.Certificate;//Get the certificate detailsstring subjectName = certificate.SubjectName;string issuerName = certificate.IssuerName;thanksiosman
thanks for the information.
SS
Sarasilmiya Shahul Hameed
Syncfusion Team
November 12, 2019 09:18 AM UTC
Hi iosman,
Most welcome. Please get back to us if you need further assistance.
Regards,
Sara
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
IM ios man
- Nov 7, 2019 03:01 AM UTC
- Nov 12, 2019 09:18 AM UTC