Update PDF Signature fields, and update digitial certificate

We have a process that is used to digitally sign signature fields, and then a digital certificate is applied. Unfortunately, some of the documents were not properly created and some of the signature fields are blank. I am in the process of trying to go back and update the signature fields, and re-sign the document. When I try to re-apply the certificate I get:

System.ArgumentException
  HResult=0x80070057
  Message=The document may contain at most one author signature!
  Source=Syncfusion.Pdf.Portable
  StackTrace:
   at Syncfusion.Pdf.Security.PdfSignature.set_Certificated(Boolean value)

Is there a way I can update the fields, and re-sign the document? I have tried this but unfortunately that removes the very fields I am trying to update. I have also tried applying a second signature as in this example but I still get the same error.


2 Replies

TI Tim May 26, 2022 03:52 PM UTC

This is the code that is applying the certificate and generating the error:

            // https://www.syncfusion.com/forums/149141/how-to-enable-disable-re-sign-pdf-after-pdf-has-been-signed-with-syncfusion
            var signature = new PdfSignature(_pdf, _pdf.Pages[_pdf.PageCount - 1], signingCertificate, $"Signed With Redacted")
            {
                Bounds = new RectangleF(0, 0, 0, 0),
                Certificated = true,
                DocumentPermissions = PdfCertificationFlags.ForbidChanges // PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.AllowComments // 
            };


IJ Irfana Jaffer Sadhik Syncfusion Team May 27, 2022 01:47 PM UTC

Hi Tim,


We can’t be able to resign the pdf document which already has a signature field in it. We need to remove the signature field before adding certified signature to the pdf document by using the Remove API. We have attached a sample to demonstrate the working of the same. Kindly try this in your end and let us know if it satisfies your requirement.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample1500943561

Document: https://www.syncfusion.com/downloads/support/directtrac/general/pd/Output_1-1794659268


Also, if you need both the signature to be appeared in your document. Please make the following highlighted code snippet changes:

PdfSignature signature = new PdfSignature(loadedDocument, loadedDocument.Pages[0], pdfCert, "Signature");

signature.Certificated = true;


Please let us know if you need any further assistance in this.


Regards,

Irfana J.


Loader.
Up arrow icon