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:
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimport(BarcodeSignOptions,DigitalSignOptions,QrCodeSignOptions,TextSignOptions)fromgroupdocs.signature.domainimportBarcodeTypes,QrCodeTypesdefsign_with_multiple_signatures():withSignature("sample.pdf")assignature:# Define text signature optionstext_options=TextSignOptions("This is test message")text_options.left=100text_options.top=360text_options.width=200text_options.height=30# Define barcode signature optionsbarcode_options=BarcodeSignOptions("123456")barcode_options.encode_type=BarcodeTypes.CODE128barcode_options.left=100barcode_options.top=420barcode_options.width=200barcode_options.height=60# Define QR code signature optionsqrcode_options=QrCodeSignOptions("JohnSmith")qrcode_options.encode_type=QrCodeTypes.QRqrcode_options.left=100qrcode_options.top=520qrcode_options.width=100qrcode_options.height=100# Define digital signature options with a certificate and an appearance imagedigital_options=DigitalSignOptions("certificate.pfx")digital_options.password="1234567890"digital_options.image_file_path="signature.jpg"digital_options.left=350digital_options.top=520digital_options.width=160digital_options.height=100# Sign the document with the list of signature optionslist_options=[text_options,barcode_options,qrcode_options,digital_options]result=signature.sign("signed_multiple.pdf",list_options)print(f"Signed with {len(result.succeeded)} signatures:")foriteminresult.succeeded:print(f" {item.signature_type.name}")if__name__=="__main__":sign_with_multiple_signatures()
sample.pdf is the sample file used in this example. Click here to download it.
certificate.pfx is the sample certificate used in this example (password 1234567890). Click here to download it.
signature.jpg is the sample file used in this example. Click here to download it.
Here’s a more advanced example showing how to add multiple signatures with different styles and positions. Each signature is placed with an alignment and a margin from the page edges:
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportImageSignOptions,QrCodeSignOptions,TextSignOptionsfromgroupdocs.signature.domainimport(HorizontalAlignment,Padding,QrCodeTypes,SignatureFont,VerticalAlignment)defsign_with_multiple_signatures_advanced():withSignature("sample.pdf")assignature:# Bold text signature at the top right, below the page headertext_options=TextSignOptions("Approved by John Smith")font=SignatureFont()font.family_name="Arial"font.size=20font.bold=Truetext_options.font=fonttext_options.width=280text_options.height=40text_options.vertical_alignment=VerticalAlignment.TOPtext_options.horizontal_alignment=HorizontalAlignment.RIGHTtext_options.margin=Padding(top=170,right=20)# Stamp image in the bottom left cornerimage_options=ImageSignOptions("stamp.png")image_options.width=100image_options.height=100image_options.vertical_alignment=VerticalAlignment.BOTTOMimage_options.horizontal_alignment=HorizontalAlignment.LEFTimage_options.margin=Padding(left=20,bottom=20)# QR code in the bottom right cornerqrcode_options=QrCodeSignOptions("https://www.example.com/verify")qrcode_options.encode_type=QrCodeTypes.QRqrcode_options.width=100qrcode_options.height=100qrcode_options.vertical_alignment=VerticalAlignment.BOTTOMqrcode_options.horizontal_alignment=HorizontalAlignment.RIGHTqrcode_options.margin=Padding(right=20,bottom=20)# Sign the document with the list of signature optionslist_options=[text_options,image_options,qrcode_options]result=signature.sign("signed_multiple_advanced.pdf",list_options)print(f"Signed with {len(result.succeeded)} signatures:")foriteminresult.succeeded:print(f" {item.signature_type.name}")if__name__=="__main__":sign_with_multiple_signatures_advanced()
sample.pdf is the sample file used in this example. Click here to download it.
stamp.png is the sample file used in this example. Click here to download it.
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: