GroupDocs.Signature provides TextSignature class to manipulate text signatures and delete them from the documents over delete method. Please be aware that delete method modifies the same document that was passed to constructor of Signature class, so the example below copies the signed document first and deletes the signature from the copy.
How to delete Text signature from the document
Here are the steps to delete Text signature from the document with GroupDocs.Signature:
Create new instance of Signature class and pass source document path as a constructor parameter;
Select from list TextSignature object(s) that should be removed from the document;
Call Signature object delete method and pass one or several signatures to it; for a single signature it returns True when the signature was deleted.
This example shows how to delete Text signature that was found using search method.
importshutilfromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportTextSearchOptionsdefdelete_text_signature():# delete() saves the changes into the opened document, so work on a copyshutil.copy("signed.docx","text_signature_deleted.docx")withSignature("text_signature_deleted.docx")assignature:options=TextSearchOptions()# Return only signatures added by GroupDocs.Signature, not the document's own textoptions.skip_external=Truesignatures=signature.search([options]).signaturesprint(f"Found {len(signatures)} text signature(s)")ifnotsignatures:returntext_signature=signatures[0]ifsignature.delete(text_signature):print(f"Deleted text signature '{text_signature.text}' at "f"({text_signature.left}, {text_signature.top})")else:print(f"Text signature '{text_signature.text}' was not deleted")if__name__=="__main__":delete_text_signature()
signed.docx is the sample file used in this example. Click here to download it.