A Text electronic signature is an arbitrary text that is added to a document in a native way depending on the type of the document. GroupDocs.Signature provides the text signature feature and allows customizing a wide range of text settings - from font name, size and color to alignment, borders, shadow effects etc. This is how a text signature may look like:
How to eSign Document with Text Signature
Let’s try to add a text signature to a PDF programmatically using Python.
This example shows how to add a text signature to a document using Python:
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportTextSignOptionsfromgroupdocs.signature.domainimportSignatureFontfromgroupdocs.pydrawingimportColordefsign_with_text_signature():withSignature("sample.pdf")assignature:# Create text signature optionsoptions=TextSignOptions("John Smith")# Set signature position and sizeoptions.left=100options.top=400options.width=200options.height=50# Set text color and fontoptions.fore_color=Color.redfont=SignatureFont()font.family_name="Arial"font.size=24options.font=font# Sign the document and save the resultresult=signature.sign("signed_text.pdf",options)print(f"Signed with {len(result.succeeded)} text signature(s)")if__name__=="__main__":sign_with_text_signature()
sample.pdf is the sample file used in this example. Click here to download it.
You can customize the text signature further with additional options: alignment and margins, font style, background, border, rotation and transparency. 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.optionsimportTextSignOptionsfromgroupdocs.signature.domainimport(Background,Border,DashStyle,HorizontalAlignment,Padding,SignatureFont,TextSignatureImplementation,VerticalAlignment)fromgroupdocs.pydrawingimportColordefsign_with_text_signature_advanced():withSignature("sample.pdf")assignature:options=TextSignOptions("John Smith")# Put the signature in the bottom right corner of the pageoptions.width=220options.height=60options.horizontal_alignment=HorizontalAlignment.RIGHToptions.vertical_alignment=VerticalAlignment.BOTTOMoptions.margin=Padding(right=40,bottom=60)# Font style and text colorfont=SignatureFont()font.family_name="Arial"font.size=20font.bold=Truefont.italic=Trueoptions.font=fontoptions.fore_color=Color.dark_blue# Background, border, rotation and transparencybackground=Background()background.color=Color.light_yellowoptions.background=backgroundborder=Border()border.color=Color.dark_blueborder.dash_style=DashStyle.DASHborder.weight=2options.border=borderoptions.rotation_angle=-10options.transparency=0.2# Render the text as an image, which also draws the border on PDF pagesoptions.signature_implementation=TextSignatureImplementation.IMAGEresult=signature.sign("signed_text_advanced.pdf",options)print(f"Signed with {len(result.succeeded)} text signature(s)")if__name__=="__main__":sign_with_text_signature_advanced()
sample.pdf is the sample file used in this example. Click here to download it.
This guide explains how to add text-based signatures to documents with GroupDocs.Signature for Python via .NET. It covers configuring text properties such as font, color, size, and position, and applying the text signature to a document. The signed document is then saved with the added text signature.
More Resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: