How to remove digital signatures?

Question:

We have PDF files that cannot be edited because they have been digitally signed. It is more important to us to be able to edit the PDF, then it is to preserve the digital signature.

How can I remove the signatures so it can be edited?

Answer:

There are three things you need to do.

  1. First you need to find all the digital signature fields, and delete any signatures.

`
FieldIterator itr;
for(itr=doc.GetFieldIterator(); itr.HasNext(); itr.Next())
{
Field field = itr.Current();

if(field.GetType() == Field.Type.e_signature)
{
field.GetSDFObj().Erase(“V”); // remove crypto component
field.GetSDFObj().Erase(“AP”); // remove visual component
}
}
`

  1. Delete the signature flags entry.

doc.GetAcroForm().Erase("SigFlags");

  1. Delete any permissions entry

doc.GetRoot().Erase("Perms");

Finally, save the file so all the now unused entries are erased completely.

doc.Save(outPath, SDFDoc.SaveOptions.e_linearized);