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. Image for the cookie policy date

Adding digital signature using syncfusion adds two signatures instead of one

I am evaluating syncfusion pdf component for adding digital signature to pdf documents. When I add the signature it adds two signatures in the document instead of one.
I am using the following code for adding signature
PdfLoadedDocument document = new PdfLoadedDocument("DigitalSignaturee3.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);

Can you please tell why is it happening so. Image is attached



1 Reply

KC Karthikeyan Chandrasekar Syncfusion Team December 20, 2018 11:05 AM UTC

Hi Muhammad, 
Thank you for your update. 
When we create PdfSignature with the PdfLoadedDocument and PdfLoadedPage as a parameters, then the signature is added in to the PdfLoadedFormFieldCollection of PdfLoadedDocument. So it is not required to adding again in the PdfLoadedFormFieldCollection.  

Kindly use the below code snippet to sign an existing PDF document. 
 
PdfLoadedDocument document = new PdfLoadedDocument("../../data/Input.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(@"../../data/PDF.pfx", "syncfusion"), "SignatureField"); 
 
signatureField.Signature.Reason = "I am author of this document"; 
 
signatureField.Signature.DocumentPermissions = PdfCertificationFlags.AllowComments | PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges; 
 
document.Save(); 
 
//Closes the document 
document.Close(true); 
 
 
Refer the below UG to sign an existing PDF document. 
 
Refer the below KB to add multiple signature to the PDF. 
Regards, 
Karthikeyan 


Loader.
Live Chat Icon For mobile
Up arrow icon