We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Verify Pdf hasn't modified after adding signature?.

Thread ID:

Created:

Updated:

Platform:

Replies:

148883 Nov 7,2019 03:01 AM UTC Nov 13,2019 02:25 PM UTC WinForms 3
loading
Tags: PDF
ios man
Asked On November 7, 2019 03:01 AM UTC

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

Sowmiya Loganathan [Syncfusion]
Replied On 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; 


Please try the above sample in your end and let us know the result.  

Regards, 
Sowmiya Loganathan 


ios man
Replied On November 11, 2019 06:53 AM UTC

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

thanks for the information.


Sarasilmiya Shahul Hameed [Syncfusion]
Replied On November 12, 2019 09:18 AM UTC

Hi iosman, 
  
Most welcome. Please get back to us if you need further assistance. 
  
Regards, 
Sara 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon