Search for Text e-Signatures

GroupDocs.Signature for Python via .NET provides the TextSearchOptions class to specify different options for searching Text electronic signatures within documents.

Here are the steps to search for Text e-signatures using GroupDocs.Signature API:

  • Create a new instance of the Signature class and pass the source document path as a constructor parameter.
  • Instantiate the TextSearchOptions object according to your requirements and specify additional search options (if needed).
  • Call the search method of the Signature class instance and pass a list with the TextSearchOptions to it. The signatures property of the returned SearchResult holds the found TextSignature objects.

This example shows how to search for Text e-signatures in a document using Python. The signature_implementation property of each signature tells how it was added to the document: as page content (NATIVE), an annotation, a form field and so on.

from groupdocs.signature import Signature
from groupdocs.signature.options import TextSearchOptions

def search_text():
    with Signature("signed.pdf") as signature:
        result = signature.search([TextSearchOptions()])

        print(f"Found {len(result.signatures)} text signature(s)")
        for text_signature in result.signatures:
            print(f"{text_signature.signature_implementation.name} text signature '{text_signature.text}' "
                  f"on page {text_signature.page_number} at ({text_signature.left}, {text_signature.top}), "
                  f"size {text_signature.width}x{text_signature.height}")

if __name__ == "__main__":
    search_text()
signed.pdf is the sample file used in this example. Click here to download it.
Found 3 text signature(s)
ANNOTATION text signature 'Approved' on page 1 at (50, 480), size 90x22
FORM_FIELD text signature 'John Smith' on page 1 at (50, 530), size 190x22
NATIVE text signature 'John Smith' on page 1 at (50, 379), size 189x30

Download full output

Advanced Search Options

Here’s an example showing how to use more advanced search options: a page to search, the text to match with its TextMatchType, and the TextSignatureImplementation to look for.

from groupdocs.signature import Signature
from groupdocs.signature.domain import TextMatchType, TextSignatureImplementation
from groupdocs.signature.options import TextSearchOptions

def search_text_with_filters():
    with Signature("signed.pdf") as signature:
        options = TextSearchOptions()
        # Search the first page only (page numbers start at 1)
        options.all_pages = False
        options.page_number = 1
        # Return only text signatures that contain "John"...
        options.text = "John"
        options.match_type = TextMatchType.CONTAINS
        # ...and are part of the page content
        options.signature_implementation = TextSignatureImplementation.NATIVE

        result = signature.search([options])

        print(f"Found {len(result.signatures)} matching text signature(s)")
        for text_signature in result.signatures:
            print(f"'{text_signature.text}' on page {text_signature.page_number} "
                  f"at ({text_signature.left}, {text_signature.top}), "
                  f"size {text_signature.width}x{text_signature.height}")

if __name__ == "__main__":
    search_text_with_filters()
signed.pdf is the sample file used in this example. Click here to download it.
Found 1 matching text signature(s)
'John Smith' on page 1 at (50, 379), size 189x30

Download full output

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.