Complete removal of digital signatures

Hi. I have tried to remove the digital signatures from pdfs using the code as described here: Remove Signature from PDF File|Aspose.PDF for .NET.

It looks like the signature is removed but not everything related to digital signatures are removed. This leads to a situation where some third party tools consider that the document still has digital signatures.
For example sigflags etc are not removed. Is there any way to completely remove everything related to digital signatures?

@Georg3

Cause

When removing digital signatures from a PDF, it’s common for some residual elements related to the signature, such as signature flags, to remain. This can lead to third-party tools still recognizing the document as signed.

Solution

To ensure complete removal of all elements related to digital signatures, you can follow these steps:

  1. Remove the Signature: Use the provided method to remove the signature from the PDF.
  2. Clear Signature Flags: After removing the signature, you should also clear any signature-related flags in the document.
  3. Save the Document: Finally, save the document to ensure all changes are applied.

Here’s a code snippet that demonstrates how to achieve this:

using Aspose.Pdf;
using Aspose.Pdf.Facades;

// Load the PDF document
Document pdfDocument = new Document("input.pdf");

// Remove the signature
SignatureField signatureField = pdfDocument.Form["SignatureFieldName"] as SignatureField;
if (signatureField != null)
{
    pdfDocument.Form.RemoveField("SignatureFieldName");
}

// Clear signature flags (if applicable)
pdfDocument.Signatures.Clear(); // This clears all signatures
pdfDocument.Save("output.pdf");

Next Steps

  1. Test the above code to ensure that all signature-related elements are removed.
  2. Verify the output PDF using your third-party tools to confirm that it no longer recognizes any digital signatures.
  3. If issues persist, check the PDF structure for any remaining signature-related metadata and address them accordingly.

Please implement these steps and let me know if you need further assistance!

Sources:
[1]: Remove Signature from PDF File - Aspose Documentation

This does not work. Do you have any other recommendation?

@Georg3

Would you kindly share your sample source and output PDF document that you obtained in your environment? Also, please share how you are checking sigflags at your end (Maybe a screenshot). We will log an investigation ticket in our issue management system and share the ID with you.

DigitallySign_out.pdf (885.0 KB)

DigitallySign_out_original.pdf (888.1 KB)

This actually happens on any file that contains digital signature. You can just open it in any editor and see the SigFlags etc.

@Georg3

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-60211

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi. Are there any updates on the issue?

@Georg3

It works as expected with the RemoveSignature(SignatureName signName) method. Please do not use the obsolete methods RemoveSignature(string signName) and GetSignNames(). Please use the code snippet below:

using (var pdFileSignature = new Aspose.Pdf.Facades.PdfFileSignature())
{
    pdFileSignature.BindPdf("input.pdf");
    var sigNames = pdFileSignature.GetSignatureNames();
    for (int index = 0; index < sigNames.Count; index++)
    {
        Console.WriteLine($"Removed {sigNames[index]}");
        pdFileSignature.RemoveSignature(sigNames[index]);
    }
    pdFileSignature.Save("output.pdf");
}

The issues you have found earlier (filed as PDFNET-60211) have been fixed in Aspose.PDF for .NET 25.8.