GroupDocs.Signature for Python via .NET provides functionality to manipulate QR code signatures’ location and size.
Please note that the update method modifies the same document that was passed to the constructor of the Signature class, so the example below copies the signed document first and updates the copy.
Here are the steps to update a QR code signature in a document with GroupDocs.Signature:
Create a new instance of the Signature class and pass the source document path as a constructor parameter
Call the search method; the signatures property of the returned SearchResult holds the found QR code signatures
Select from the list the QrCodeSignature object(s) that should be updated and change their position or size
Call the Signature object’s update method and pass one or several signatures to it; for a single signature it returns True when the signature was updated
This example shows how to update a QR code signature that was found using the search method:
importshutilfromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportQrCodeSearchOptionsdefupdate_qr_code_signature():# update() saves the changes into the opened document, so work on a copyshutil.copy("signed.docx","updated_qr_code_signature.docx")withSignature("updated_qr_code_signature.docx")assignature:signatures=signature.search([QrCodeSearchOptions()]).signaturesprint(f"Found {len(signatures)} QR code signature(s)")ifnotsignatures:returnqr_code_signature=signatures[0]# Change the positionqr_code_signature.left=440qr_code_signature.top=600# Change the size. Not all document formats support resizing a signatureqr_code_signature.width=140qr_code_signature.height=140ifsignature.update(qr_code_signature):print(f"QR code '{qr_code_signature.text}' ({qr_code_signature.encode_type.type_name}) "f"moved to ({qr_code_signature.left}, {qr_code_signature.top}) "f"and resized to {qr_code_signature.width}x{qr_code_signature.height}")else:print(f"QR code '{qr_code_signature.text}' was not updated")if__name__=="__main__":update_qr_code_signature()
signed.docx is the sample file used in this example. Click here to download it.