Search for Metadata e-Signatures

GroupDocs.Signature provides the ability to search for metadata electronic signatures in documents. Metadata signatures allow you to add custom metadata properties to your documents, which can be used to store additional information about the document or its signatures.

How to Search for Metadata Signatures

The Signature class provides the search method which allows you to search for metadata signatures in documents. Here’s how to use it:

  1. Create a new instance of the Signature class and pass the source document path as a parameter.
  2. Create an instance of MetadataSearchOptions class.
  3. Call the search method of the Signature class instance and pass a list with the search options to it.
  4. Process the search results: the signatures property of the returned SearchResult holds the found MetadataSignature objects, each with a name, a value and a value type.

Here’s an example of how to search for metadata signatures in a document. The result includes the document’s standard properties, such as Producer and CreateDate, as well as the custom ones:

from groupdocs.signature import Signature
from groupdocs.signature.options import MetadataSearchOptions


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

        print(f"Found {len(result.signatures)} metadata signature(s)")
        for metadata in result.signatures:
            print(f"{metadata.name} = {metadata.value} ({metadata.type.name})")


if __name__ == "__main__":
    search_metadata()

signed.pdf is the sample file used in this example. Click here to download it.

Found 10 metadata signature(s)
Producer = Microsoft® Word 2016 (STRING)
creator = DrNasmork (STRING)
CreatorTool = Microsoft® Word 2016 (STRING)
CreateDate = 2020-08-03 20:04:25+03:00 (DATE_TIME)
ModifyDate = 2020-08-03 20:04:25+03:00 (DATE_TIME)
Author = John Smith (STRING)
DocumentId = DOC-2026-0042 (STRING)
Department = Sales (STRING)
DocumentID = uuid:D7DC5B44-D1CC-453B-BC66-B0362EAE6617 (STRING)
[TRUNCATED]

Download full output

Advanced Search Options

You can search for metadata signatures by name: set the name property of MetadataSearchOptions and choose how it is compared with name_match_type (TextMatchType):

from groupdocs.signature import Signature
from groupdocs.signature.domain import TextMatchType
from groupdocs.signature.options import MetadataSearchOptions


def search_metadata_by_name():
    with Signature("signed.pdf") as signature:
        options = MetadataSearchOptions()
        # Return only the metadata signature named "Author"
        options.name = "Author"
        options.name_match_type = TextMatchType.EXACT

        result = signature.search([options])

        print(f"Found {len(result.signatures)} matching metadata signature(s)")
        for metadata in result.signatures:
            print(f"{metadata.name} = {metadata.value}")


if __name__ == "__main__":
    search_metadata_by_name()

signed.pdf is the sample file used in this example. Click here to download it.

Found 1 matching metadata signature(s)
Author = John Smith

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.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.