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.
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportTextSearchOptionsdefsearch_text():withSignature("signed.pdf")assignature:result=signature.search([TextSearchOptions()])print(f"Found {len(result.signatures)} text signature(s)")fortext_signatureinresult.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
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.
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.domainimportTextMatchType,TextSignatureImplementationfromgroupdocs.signature.optionsimportTextSearchOptionsdefsearch_text_with_filters():withSignature("signed.pdf")assignature:options=TextSearchOptions()# Search the first page only (page numbers start at 1)options.all_pages=Falseoptions.page_number=1# Return only text signatures that contain "John"...options.text="John"options.match_type=TextMatchType.CONTAINS# ...and are part of the page contentoptions.signature_implementation=TextSignatureImplementation.NATIVEresult=signature.search([options])print(f"Found {len(result.signatures)} matching text signature(s)")fortext_signatureinresult.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