GroupDocs.Signature for Python via .NET allows signing a document with several signatures simultaneously and even apply signatures of different types to the same document.
Doing this is as simple as:
Create a new instance of the Signature class and pass the source document path or stream as a constructor parameter.
Instantiate all required sign options objects depending on signature type:
Fill the collection with sign options from the previous step.
Call the Sign method of the Signature class instance and pass the collection of sign options to it.
This code snippet below demonstrates how to eSign a PDF document with multiple signatures at the same time using Python:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportTextSignOptions,BarcodeSignOptions,QrCodeSignOptions,DigitalSignOptionsfromgroupdocs.signature.domainimportBarcodeTypes,QrCodeTypesimportgroupdocs.signature.domainasgsdimportsysimportosdefrun():withsignature.Signature("./sample.pdf")assign:# Define text signature optionstext_options=TextSignOptions("This is test message")text_options.vertical_alignment=gsd.VerticalAlignment.TOPtext_options.horizontal_alignment=gsd.HorizontalAlignment.LEFT# Define barcode signature optionsbarcode_options=BarcodeSignOptions("123456")barcode_options.encode_type=BarcodeTypes.CODE_128barcode_options.left=100barcode_options.top=100# Define QR code signature optionsqrcode_options=QrCodeSignOptions("JohnSmith")qrcode_options.encode_type=QrCodeTypes.QRqrcode_options.left=100qrcode_options.top=200# Define digital signature optionsdigital_options=DigitalSignOptions("./certificate.pfx")digital_options.image_file_path="./signature.jpg"digital_options.vertical_alignment=gsd.VerticalAlignment.CENTERdigital_options.horizontal_alignment=gsd.HorizontalAlignment.CENTERdigital_options.password="1234567890"# Define list of signature optionslist_options=[text_options,barcode_options,qrcode_options,digital_options]# Sign documentsign.sign("./signed.pdf",list_options)
The following sample file is used in this example: sample.pdf
The following sample file is used in this example: signature.jpg
Advanced Multiple Signatures Example
Here’s a more advanced example showing how to add multiple signatures with different styles and positions:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportTextSignOptions,ImageSignOptions,QrCodeSignOptionsfromgroupdocs.signature.domainimportQrCodeTypesimportgroupdocs.signature.domainasgsdimportsysimportosdefrun():withsignature.Signature("./sample.pdf")assign:# Create text signature optionstext_options=TextSignOptions("Approved by John Smith")text_options.font=gsd.SignatureFont()text_options.font.bold=Truetext_options.font.size=20.0text_options.font.family_name="Arial"text_options.vertical_alignment=gsd.VerticalAlignment.TOPtext_options.horizontal_alignment=gsd.HorizontalAlignment.RIGHTtext_options.margin=gsd.Padding(10,10,0,0)# Create image signature optionsimage_options=ImageSignOptions("./stamp.png")image_options.width=200image_options.height=100image_options.vertical_alignment=gsd.VerticalAlignment.BOTTOMimage_options.horizontal_alignment=gsd.HorizontalAlignment.LEFTimage_options.margin=gsd.Padding(0,0,10,10)# Create QR code signature optionsqrcode_options=QrCodeSignOptions("https://www.example.com/verify")qrcode_options.encode_type=QrCodeTypes.QRqrcode_options.width=100qrcode_options.height=100qrcode_options.vertical_alignment=gsd.VerticalAlignment.CENTERqrcode_options.horizontal_alignment=gsd.HorizontalAlignment.CENTER# Define list of signature optionslist_options=[text_options,image_options,qrcode_options]# Sign documentsign.sign("./signed.pdf",list_options)
The following sample file is used in this example: sample.pdf
Summary
This guide demonstrates how to apply multiple types of electronic signatures (e.g., text, barcode, image) to a document using GroupDocs.Signature for Python via .NET. It explains how to combine different signature types, configure each one, and save the signed document with multiple signature styles.
More Resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: