How to Search for QR Code Signatures

When you search for electronic signatures of QR-Code type inside a document with GroupDocs.Signature for Python via .NET, you only need to pass a list with a QrCodeSearchOptions object to the search method.

Here’s a quick guide on how to search for QR-code signatures:

The code snippet below demonstrates how to search for QR-code signatures in a document using Python:

from groupdocs.signature import Signature
from groupdocs.signature.options import QrCodeSearchOptions


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

        print(f"Found {len(result.signatures)} QR code signature(s)")
        for qr_code in result.signatures:
            print(f"QR code signature found at page {qr_code.page_number} "
                  f"with type {qr_code.encode_type.type_name} and text '{qr_code.text}'")


if __name__ == "__main__":
    search_qr_codes()

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

Found 1 QR code signature(s)
QR code signature found at page 1 with type QR and text 'John Smith'

Download full output

Advanced Search Options

Here’s an example showing how to use more advanced search options for QR codes: a page to search, the QR code type (QrCodeTypes) and the text to match.

from groupdocs.signature import Signature
from groupdocs.signature.domain import QrCodeTypes, TextMatchType
from groupdocs.signature.options import QrCodeSearchOptions


def search_qr_codes_with_filters():
    with Signature("signed.pdf") as signature:
        options = QrCodeSearchOptions()
        # Search the first page only (page numbers start at 1)
        options.all_pages = False
        options.page_number = 1
        # Return only QR codes of the QR type...
        options.encode_type = QrCodeTypes.QR
        # ...whose text contains "John"
        options.text = "John"
        options.match_type = TextMatchType.CONTAINS

        result = signature.search([options])

        print(f"Found {len(result.signatures)} matching QR code signature(s)")
        for qr_code in result.signatures:
            print(f"Text: {qr_code.text}")
            print(f"Page number: {qr_code.page_number}")
            print(f"Position: X={qr_code.left}, Y={qr_code.top}")
            print(f"Size: {qr_code.width}x{qr_code.height}")
            print(f"Encode type: {qr_code.encode_type.type_name}")


if __name__ == "__main__":
    search_qr_codes_with_filters()

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

Found 1 matching QR code signature(s)
Text: John Smith
Page number: 1
Position: X=270, Y=370
Size: 100x100
Encode type: QR

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.