We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Sign PDF by two authorities

How we can sign Aspose PDF more than once? I am trying it but it is giving me exception “You cannot change this document because it is certified.”


We can sign a PDF document more than once. Please send all details of the scenario, including source documents and code. We will investigate your scenario in our environment, and share our findings with you.

This is the code I am using for signing PDF Document

        using (PdfFileSignature signature = new PdfFileSignature(pdfDocument))
            Aspose.Pdf.Forms.PKCS7 pkcs = new Aspose.Pdf.Forms.PKCS7("C:\\Users\\Rahul.Chavan\\Desktop\\subca.pfx", "raykor"); // Use PKCS7/PKCS7Detached objects
            Aspose.Pdf.Forms.DocMDPSignature docMdpSignature = new Aspose.Pdf.Forms.DocMDPSignature(pkcs, Aspose.Pdf.Forms.DocMDPAccessPermissions.FillingInForms);
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(50,50,100,50);
            // Set signature appearance
            signature.SignatureAppearance = PsDocument.Replace("sign.pdf", ".jpg");
            // Create any of the three signature types
            signature.Certify(1, "2 Signature Reason", "2 Contact", "2 Location", true, rect, docMdpSignature);
            // Save output PDF file
            signature.Save(PsDocument.Replace(".pdf", "2.pdf"));

And for signing it two times I am calling same code second time with different PFX File.

And the pdf document with whichI am facing issue is toc.zip (112.1 KB)

Please share your findings and code snippet.


Please send us your source PFX files and passwords. We need to replicate the same error in our environment. Your response is awaited.

pfx.zip (5.2 KB)
Please find the attached PFX and the password is mentioned in password.txt file in zip attached.


Please try the code as follows:

string dataDir = @"C:\Pdf\test877\";
Document doc = new Document(dataDir + "toc.pdf");
//place empty signatures
SignatureField s1 = new SignatureField(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 200, 300, 100));
SignatureField s2 = new SignatureField(doc.Pages[2], new Aspose.Pdf.Rectangle(200, 200, 300, 100));
doc.Save(dataDir + "presign_output.pdf");
//create PdfFileSignature object and bind input and output PDF files
PdfFileSignature pdfSign = new PdfFileSignature(dataDir + "presign_output.pdf", dataDir + @"sign_output.pdf");
//create any of the three signature types
PKCS1 signature1 = new PKCS1(dataDir + "rc.pfx", "raykor");
signature1.Reason = "Signature Reason";
signature1.ContactInfo = "Pius";
signature1.Location = "Nairobi";
PKCS1 signature2 = new PKCS1(dataDir + "subca.pfx", "raykor");
signature2.Reason = "Signature Reason";
signature2.ContactInfo = "Pius Bg";
signature2.Location = "Newyork";
//place first signature
pdfSign.Sign(s1.PartialName, signature1);
//place second signature
pdfSign = new PdfFileSignature(dataDir + @"sign_output.pdf", dataDir + @"sign_outputfinal.pdf");
pdfSign.Sign(s2.PartialName, signature2);

This is the output PDF document: sign_outputfinal.pdf (216.9 KB)

Hello, how should I code for a scenario where I want first to certify a PDF and then add a couple of approval signatures for pre-existing signature fields. The following code still does not work:

public static void Go3(X509Certificate2 certificate)
  string dataDir = @"C:\TestFiles\";

  string s1Name = null;
  string s2Name = null;

  using (var doc = new Document(dataDir + "test_source.pdf"))
    SignatureField s1 = new SignatureField(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 200, 300, 100));
    s1Name = s1.PartialName;

    SignatureField s2 = new SignatureField(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 300, 300, 100));
    s2Name = s2.PartialName;

    doc.Save(dataDir + "test_source_with_fields.pdf");

  using (var signature = new PdfFileSignature())
    signature.BindPdf(dataDir + "test_source_with_fields.pdf");
    signature.SignatureAppearance = dataDir + @"image.jpg";
    DocMDPSignature docMdpSignature = new DocMDPSignature(new ExternalSignature(certificate), DocMDPAccessPermissions.FillingInForms);
    signature.Certify(1, "Reason", "Contact", "Location",
      visible: true, annotRect: new System.Drawing.Rectangle(100, 100, 200, 100), docMdpSignature: docMdpSignature);
    signature.Save(dataDir + "test_source_with_fields_certified.pdf");

  using (var signature = new PdfFileSignature())
    signature.BindPdf(dataDir + "test_source_with_fields_certified.pdf");
    var secondSignature = new ExternalSignature(certificate);
    signature.Sign(s1Name, secondSignature);
    signature.Save(dataDir + "test_source_with_fields_certified_s2.pdf");

The line signature.Sign(s1Name, secondSignature); still raises this exception:

  Message=You cannot change this document because it is certified.
   at Aspose.Pdf.Facades.PdfFileSignature.#=zWCx87Tn4zsn_()
   at Aspose.Pdf.Facades.PdfFileSignature.Sign(String SigName, String SigReason, String SigContact, String SigLocation, Signature sig)
   at Aspose.Pdf.Facades.PdfFileSignature.Sign(String SigName, Signature sig)
   at ConsolePlaygroundApp1.AsposePdfTest.Go3(X509Certificate2 certificate) 


Would you kindly share your sample PDF document along with signature files. We will test the scenario in our environment and address it accordingly.