GroupDocs.Signature supports verification of documents for different signature types. This approach requires to add all required verification options to list.
Here are the steps to verify document for multiple signatures with GroupDocs.Signature:
Create new instance of Signature class and pass source document path or stream as a constructor parameter.
Call verify method of Signature class instance and pass filled list of VerifyOptions to it. The is_valid property of the returned VerificationResult is True only when every options object in the list matches a valid signature; succeeded lists the signatures that passed.
This example shows how to verify the document for different signature types.
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.domainimportTextMatchType,TextSignatureImplementationfromgroupdocs.signature.optionsimport(BarcodeVerifyOptions,DigitalVerifyOptions,QrCodeVerifyOptions,TextVerifyOptions)defverify_multiple_signature_types():withSignature("signed.pdf")assignature:# Text signature that contains "John"text_options=TextVerifyOptions()text_options.all_pages=True# this value is set by defaulttext_options.signature_implementation=TextSignatureImplementation.NATIVEtext_options.text="John"text_options.match_type=TextMatchType.CONTAINS# Barcode signature that contains "12345"barcode_options=BarcodeVerifyOptions()barcode_options.text="12345"barcode_options.match_type=TextMatchType.CONTAINS# QR code signature that contains "John"qr_code_options=QrCodeVerifyOptions()qr_code_options.text="John"qr_code_options.match_type=TextMatchType.CONTAINS# Digital signature made with this certificate for the reason "Approved"digital_options=DigitalVerifyOptions("certificate.pfx")digital_options.password="1234567890"digital_options.reason="Approved"result=signature.verify([text_options,barcode_options,qr_code_options,digital_options])ifresult.is_valid:print("Document was verified successfully!")else:print("Document failed verification process.")forverifiedinresult.succeeded:print(f"Verified {verified.signature_type.name} signature")if__name__=="__main__":verify_multiple_signature_types()
signed.pdf is the sample file used in this example. Click here to download it.
certificate.pfx is the sample file used in this example. Click here to download it.
Document was verified successfully!
Verified TEXT signature
Verified BARCODE signature
Verified QR_CODE signature
Verified DIGITAL signature