Search for Multiple e-Signature Types

GroupDocs.Signature provides the ability to search for multiple types of electronic signatures in documents simultaneously. This allows you to find different types of signatures like text, image, digital, barcode, QR code, and form field signatures in a single search operation.

How to Search for Multiple Signature Types

The Signature class provides the search method which allows you to search for multiple types of 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 search options for each type of signature you want to search for.
  3. Call the search method of the Signature class instance and pass the list of search options to it.
  4. Process the search results: the signatures property of the returned SearchResult holds the signatures of all requested types. The signature_type property of each one tells its SignatureType.

Here’s an example of how to search for multiple types of signatures in a document:

from groupdocs.signature import Signature
from groupdocs.signature.options import (BarcodeSearchOptions, FormFieldSearchOptions, ImageSearchOptions,
                                         QrCodeSearchOptions, TextSearchOptions)


def search_types():
    with Signature("signed.pdf") as signature:
        # One search call with options for every signature type to find
        options = [
            TextSearchOptions(),
            ImageSearchOptions(),
            BarcodeSearchOptions(),
            QrCodeSearchOptions(),
            FormFieldSearchOptions(),
        ]
        result = signature.search(options)

        print(f"Found {len(result.signatures)} signature(s)")
        for found in result.signatures:
            print(f"{found.signature_type.name} signature on page {found.page_number} "
                  f"at ({found.left}, {found.top})")


if __name__ == "__main__":
    search_types()

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

Found 10 signature(s)
TEXT signature on page 1 at (50, 480)
TEXT signature on page 1 at (50, 530)
TEXT signature on page 1 at (50, 379)
IMAGE signature on page 1 at (50, 415)
BARCODE signature on page 1 at (400, 375)
BARCODE signature on page 1 at (400, 430)
QR_CODE signature on page 1 at (270, 370)
FORM_FIELD signature on page 1 at (50, 530)
FORM_FIELD signature on page 1 at (270, 532)
[TRUNCATED]

Download full output

Advanced Search Options

You can customize the search process for each signature type by setting the properties of its search options:

from groupdocs.signature import Signature
from groupdocs.signature.domain import BarcodeTypes, QrCodeTypes, SignatureType, TextMatchType
from groupdocs.signature.options import BarcodeSearchOptions, MetadataSearchOptions, QrCodeSearchOptions


def search_types_with_filters():
    with Signature("signed.pdf") as signature:
        # Code 128 barcodes only
        barcode_options = BarcodeSearchOptions()
        barcode_options.encode_type = BarcodeTypes.CODE128
        # QR codes whose text contains "John"
        qr_code_options = QrCodeSearchOptions()
        qr_code_options.encode_type = QrCodeTypes.QR
        qr_code_options.text = "John"
        qr_code_options.match_type = TextMatchType.CONTAINS
        # The "Author" metadata property
        metadata_options = MetadataSearchOptions()
        metadata_options.name = "Author"

        result = signature.search([barcode_options, qr_code_options, metadata_options])

        print(f"Found {len(result.signatures)} signature(s)")
        for found in result.signatures:
            if found.signature_type == SignatureType.METADATA:
                print(f"METADATA: {found.name} = {found.value}")
            else:
                print(f"{found.signature_type.name} on page {found.page_number}: {found.text}")


if __name__ == "__main__":
    search_types_with_filters()

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

Found 3 signature(s)
BARCODE on page 1: 123456789012
QR_CODE on page 1: John Smith
METADATA: 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.