A form field is an interactive element located on a document page that allows user data input through various control types like free input text boxes, multi-line text boxes, checkboxes, drop-down lists, etc. Different document types support a specific list of form field types. These elements are used to collect information from users on template form. Each Form Field element has a unique name, settings and value field. Form Fields should have unique names within the form. The picture below demonstrates a possible document page with form fields.
Currently GroupDocs.Signature supports the creation of Form Field signatures for PDF documents only.
This example shows how to sign a PDF document with a Form Field electronic signature using Python:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportFormFieldSignOptionsfromgroupdocs.signature.domainimportTextFormFieldSignatureimportgroupdocs.signature.domainasgsdimportsysimportosdefrun():withsignature.Signature("./sample.pdf")assign:# Create text form field signaturetext_signature=TextFormFieldSignature("FieldText","Value1")# Create form field optionsoptions=FormFieldSignOptions(text_signature)# Set signature position and sizeoptions.horizontal_alignment=gsd.HorizontalAlignment.LEFToptions.vertical_alignment=gsd.VerticalAlignment.TOPoptions.margin=gsd.Padding(10,20,0,0)options.height=10options.width=100# Sign documentsign.sign("./SampleSigned.pdf",options)
How to eSign Document with Existing Form Field Signatures
GroupDocs.Signature for Python via .NET also provides a mechanism to update the existing form field signatures within the documents.
To update an existing form field signature within the document with GroupDocs.Signature:
Create a new instance of the Signature class and pass the source document path as a constructor parameter.
Instantiate the TextSignOptions object with all required additional options.
Analyze the SignResult object to check the newly created signatures if needed.
This example shows how to sign a PDF document with the existing Form Field electronic signature and update its value using Python:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportTextSignOptionsfromgroupdocs.signature.domainimportFormTextFieldType# Initialize signaturewithsignature.Signature("sample.pdf")assign:# Create first form field optionsff_options1=TextSignOptions("Document is approved")ff_options1.signature_implementation=signature.TextSignatureImplementation.FORM_FIELDff_options1.form_text_field_type=FormTextFieldType.PLAIN_TEXT# Create second form field optionsff_options2=TextSignOptions("John Smith")ff_options2.signature_implementation=signature.TextSignatureImplementation.FORM_FIELDff_options2.form_text_field_type=FormTextFieldType.RICH_TEXTff_options2.form_text_field_title="UserSignatureFullName"# Create list of optionslist_options=[ff_options1,ff_options2]# Sign documentsign_result=sign.sign("SampleSigned.pdf",list_options)
Summary
This guide explains how to use GroupDocs.Signature for Python via .NET to add form field signatures to documents. It covers loading a document, configuring form field properties such as name, type, and value, and saving the signed document. Advanced options, like customizing field appearance and placement, are also included. For more details, refer to related guides on document signing techniques.
More Resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: