Verify QR Code Signatures in Document

GroupDocs.Signature for Python via .NET provides functionality to verify QR code signatures in documents. This guide demonstrates how to verify QR code signatures using Python.

Basic Usage Example

Here’s a simple example showing how to verify QR code signatures in a document:

import groupdocs.signature as signature
from groupdocs.signature.options import QrCodeVerifyOptions
import groupdocs.signature.domain as gsd
# Initialize signature
with signature.Signature("sample_signed.pdf") as sign:
    # Create verification options
    options = QrCodeVerifyOptions()
    options.text = "https://www.example.com"
    options.match_type = gsd.TextMatchType.Contains
    options.all_pages = True  # verify on all pages
    
    # Verify signatures
    result = sign.verify(options)
    
    if result.is_valid:
        print("Document was verified successfully!")
    else:
        print("Document failed verification process.")

Advanced Usage Example

Here’s an example showing more advanced verification options:

import groupdocs.signature as signature
from groupdocs.signature.options import QrCodeVerifyOptions

# Initialize signature
with signature.Signature("sample_signed.pdf") as sign:
    # Create verification options with advanced settings
    options = QrCodeVerifyOptions()
    options.text = "https://www.example.com"
    options.match_type = signature.TextMatchType.Exact  # require exact match
    options.qr_code_type = signature.QrCodeType.QR  # specify QR code type
    options.all_pages = False  # verify only on specific pages
    options.page_numbers = [1, 2]  # verify on pages 1 and 2
    
    # Verify signatures
    result = sign.verify(options)
    
    if result.is_valid:
        print("Document was verified successfully!")
        # Print verification details
        for signature in result.succeeded:
            print(f"Found valid QR code: {signature.text}")
    else:
        print("Document failed verification process.")
        # Print failed verification details
        for signature in result.failed:
            print(f"Invalid QR code: {signature.text}")

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 verify PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.