Remove digital signature from pdf document failed

Hi @asad.ali
Not able to remove digital signature from pdf document.
Code:
String dataDir = “D:\degital signature\”;
PdfFileSignature pdfSign = new PdfFileSignature();
// Open PDF document
pdfSign.bindPdf(dataDir + “out_2.90.pdf”);
// Get list of signature names
List names = pdfSign.getSignNames();
System.out.println(names);
// Remove all the signatures from the PDF file
for (int index = 0; index < names.size(); index++)
{
pdfSign.removeSignature(names.get(index));
}
// Save updated PDF file
pdfSign.save(dataDir + “RemoveSignature_out.pdf”);

Exception:-
Exception in thread “main” class com.aspose.pdf.exceptions.PdfException: You cannot change this document because it is certified.
com.aspose.pdf.facades.PdfFileSignature.removeSignature(Unknown Source)
com.test.RemoveSignature.main(RemoveSignature.java:31)
at com.aspose.pdf.facades.PdfFileSignature.removeSignature(Unknown Source)
at com.test.RemoveSignature.main(RemoveSignature.java:31)

InputFile:-
out_2.90.zip (339.9 KB)

@rabinintig

We were able to reproduce the issue in our environment while using Aspose.PDF for Java 20.12. Therefore, we have logged it under the ticket ID PDFJAVA-40095 in our issue tracking system. We will further look into its detail and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

@rabinintig

We have investigated the earlier logged ticket. You are not able to change signed PDF document including removing signature fields because of missing fields. To double check whether signature fields exist or not in document, you can use following code snippet:

Document doc = new Document(dataDir + "out_2.90.pdf");
for (Field  f : doc.getForm().getFields()) {
            SignatureField sf = (SignatureField) f;
            if (sf != null){
                // Do something
                System.out.println(sf.getSignature().getReason());
            }
        }