GroupDocs.Signature for Python via .NET provides functionality to manipulate image signatures’ location, size, and other properties.
Please note that the update method modifies the same document that was passed to the constructor of the Signature class, so the example below copies the signed document first and updates the copy.
Here are the steps to update an Image signature in a document with GroupDocs.Signature:
Create a new instance of the Signature class and pass the source document path as a constructor parameter
Call the search method; the signatures property of the returned SearchResult holds the found image signatures
Select from the list the ImageSignature object(s) that should be updated and change their properties
Call the Signature object’s update method and pass one or several signatures to it; for a single signature it returns True when the signature was updated
This example shows how to update an Image signature that was found using the search method:
importshutilfromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportImageSearchOptionsdefupdate_image_signature():# update() saves the changes into the opened document, so work on a copyshutil.copy("signed.docx","updated_image_signature.docx")withSignature("updated_image_signature.docx")assignature:options=ImageSearchOptions()# Return only signatures added by GroupDocs.Signature, not the document's own imagesoptions.skip_external=Truesignatures=signature.search([options]).signaturesprint(f"Found {len(signatures)} image signature(s)")ifnotsignatures:returnimage_signature=signatures[0]# Change the positionimage_signature.left=240image_signature.top=450# Change the size. Not all document formats support resizing a signatureimage_signature.width=150image_signature.height=125ifsignature.update(image_signature):print(f"Image signature moved to ({image_signature.left}, {image_signature.top}) "f"and resized to {image_signature.width}x{image_signature.height}")else:print("Image signature was not updated")if__name__=="__main__":update_image_signature()
signed.docx is the sample file used in this example. Click here to download it.