An image as a signature is an alternative way to put any presenting data in a visual form. This electronic signature type allows the creation of custom images with a company logo, sender’s initials, names and so forth.
This example shows how to sign a PDF document with the image signature using Python:
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportImageSignOptionsdefsign_with_image_signature():withSignature("sample.pdf")assignature:# Create image signature options with the image fileoptions=ImageSignOptions("signature.jpg")# Set signature position and sizeoptions.left=100options.top=400options.width=120options.height=100# Sign the document and save the resultresult=signature.sign("signed_image.pdf",options)print(f"Signed with {len(result.succeeded)} image signature(s)")if__name__=="__main__":sign_with_image_signature()
sample.pdf is the sample file used in this example. Click here to download it.
signature.jpg is the sample file used in this example. Click here to download it.
You can customize the image signature further with additional options: alignment and margins, rotation, transparency and a border. When an alignment is set, it replaces the left or top coordinate, and the margin offsets the signature from the page edge.
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportImageSignOptionsfromgroupdocs.signature.domainimport(Border,DashStyle,HorizontalAlignment,Padding,VerticalAlignment)fromgroupdocs.pydrawingimportColordefsign_with_image_signature_advanced():withSignature("sample.pdf")assignature:options=ImageSignOptions("signature.jpg")# Put the signature in the bottom right corner of the pageoptions.width=160options.height=136options.horizontal_alignment=HorizontalAlignment.RIGHToptions.vertical_alignment=VerticalAlignment.BOTTOMoptions.margin=Padding(right=40,bottom=60)# Rotate the image and make it 20% transparentoptions.rotation_angle=10options.transparency=0.2# Draw a dashed border around the imageborder=Border()border.color=Color.dark_greenborder.dash_style=DashStyle.DASHborder.weight=2border.visible=Trueoptions.border=borderresult=signature.sign("signed_image_advanced.pdf",options)print(f"Signed with {len(result.succeeded)} image signature(s)")if__name__=="__main__":sign_with_image_signature_advanced()
sample.pdf is the sample file used in this example. Click here to download it.
signature.jpg is the sample file used in this example. Click here to download it.
You can also load the signature image from a stream. Keep the stream open until sign returns:
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportImageSignOptionsdefsign_with_image_from_stream():withSignature("sample.pdf")assignature:# Load the signature image from a streamwithopen("signature.jpg","rb")asimage_stream:options=ImageSignOptions(image_stream)options.left=100options.top=400options.width=120options.height=100result=signature.sign("signed_image_stream.pdf",options)print(f"Signed with {len(result.succeeded)} image signature(s)")if__name__=="__main__":sign_with_image_from_stream()
sample.pdf is the sample file used in this example. Click here to download it.
signature.jpg is the sample file used in this example. Click here to download it.
This guide demonstrates how to use GroupDocs.Signature for Python via .NET to add image-based signatures to documents. It covers loading a document, configuring the image signature’s properties (such as size, position, and transparency), and saving the signed document. Advanced customization options, like adjusting image appearance and aligning the signature, are also discussed. For further insights, explore related document signing resources.
More Resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: