Update Text Signatures in Document

GroupDocs.Signature for Python via .NET provides functionality to manipulate text signatures’ location, size, and textual content.
Please note that the update method modifies the same document that was passed to the constructor of the Signature class.

Here are the steps to update a Text 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
  • Instantiate the TextSearchOptions object with desired properties
  • Call the search method to obtain a list of text signatures
  • Select from the list the TextSignature object(s) that should be updated
  • Call the Signature object’s update method and pass one or several signatures to it

This example shows how to update a Text signature that was found using the search method:

import groupdocs.signature as signature
from groupdocs.signature.options import TextSearchOptions

# Initialize signature
with signature.Signature("sample_signed.pdf") as sign:
    # Create search options
    options = TextSearchOptions()
    
    # Search for text signatures in document
    signatures = sign.search(options)
    
    if len(signatures) > 0:
        # Get first text signature
        text_signature = signatures[0]
        
        # Change text property
        text_signature.text = "John Walkman"
        
        # Change position
        text_signature.left = text_signature.left + 10
        text_signature.top = text_signature.top + 10
        
        # Change size. Please note not all documents support changing signature size
        text_signature.width = 200
        text_signature.height = 100
        
        # Update the signature
        result = sign.update(text_signature)
        
        if result.updated_count > 0:
            print(f"Signature with text '{text_signature.text}' was updated in the document")
        else:
            print(f"Signature was not updated in the document! "
                  f"Signature with text '{text_signature.text}' was not found!")

More Resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online Apps

Along with the full-featured Python library, we provide simple but powerful free online apps.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.