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:
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportFormFieldSignOptionsfromgroupdocs.signature.domainimportTextFormFieldSignaturedefsign_with_form_field_signature():withSignature("sample.pdf")assignature:# Create a text form field named "FieldText" with the value "Value1"text_field=TextFormFieldSignature("FieldText","Value1")# Create form field options for itoptions=FormFieldSignOptions(text_field)# Set form field position and sizeoptions.left=100options.top=400options.width=200options.height=20# Sign the document and save the resultresult=signature.sign("signed_form_field.pdf",options)forfieldinresult.succeeded:print(f"Added form field '{field.name}' with value '{field.value}'")if__name__=="__main__":sign_with_form_field_signature()
sample.pdf is the sample file used in this example. Click here to download it.
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. The sample_form.pdf form has two text fields: ApprovalNote (plain text) and UserSignatureFullName (rich text). The form_text_field_title property names the field to fill; when it is not set, the text goes into every text field of the given form_text_field_type.
fromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportTextSignOptionsfromgroupdocs.signature.domainimportFormTextFieldType,TextSignatureImplementationdeffill_existing_form_fields():withSignature("sample_form.pdf")assignature:# Put a note into the plain-text field "ApprovalNote"note_options=TextSignOptions("Document is approved")note_options.signature_implementation=TextSignatureImplementation.FORM_FIELDnote_options.form_text_field_type=FormTextFieldType.PLAIN_TEXTnote_options.form_text_field_title="ApprovalNote"# Put the signer's name into the rich-text field "UserSignatureFullName"name_options=TextSignOptions("John Smith")name_options.signature_implementation=TextSignatureImplementation.FORM_FIELDname_options.form_text_field_type=FormTextFieldType.RICH_TEXTname_options.form_text_field_title="UserSignatureFullName"# Sign the document with both options at onceresult=signature.sign("filled_form.pdf",[note_options,name_options])print(f"Filled {len(result.succeeded)} form field(s)")if__name__=="__main__":fill_existing_form_fields()
sample_form.pdf is the sample file used in this example. Click here to download it.
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 placing the field on the page and filling the existing fields of a PDF form, 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: