GroupDocs.Editor provides classes and interfaces for the management and manipulation of form fields within Word documents. This feature allows users to interact with various types of form fields programmatically, including text fields, checkboxes, dropdowns, and more. This article covers the main features and usage of field management in GroupDocs.Editor.
Key Classes and Interfaces
IFormField
The IFormField interface represents a general form field and defines common properties shared among all form fields.
Properties
stylesheet: Gets the stylesheet associated with the form field.
readonly: Gets or sets a value indicating whether the form field is read-only.
name: Gets the name of the form field.
type: Gets the type of the form field.
locale_id: Gets or sets the locale identifier for the form field.
status_text: Gets or sets the status text associated with the form field.
help_text: Gets or sets the help text associated with the form field.
Specific Form Field Types
The API includes several classes that implement IFormField for specific types of form fields:
CheckBoxForm: Represents a checkbox form field.
DropDownFormField: Represents a dropdown form field with a list of string values.
NumberFormField: Represents a number input form field.
TextFormField: Represents a text input form field.
DateFormField: Represents a date input form field.
FormFieldCollection
The FormFieldCollection class manages a collection of form fields within a document. It allows you to enumerate, insert, and retrieve form fields by their name.
InvalidFormField
The InvalidFormField class represents an invalid form field that needs renaming. It is used in the context of fixing invalid form field names.
Properties
name: Gets the original name of the form field.
fixed_name: Gets or sets the new name for the form field after repair.
FormFieldManager
The FormFieldManager class provides a high-level interface for managing form fields in a document. It is obtained from the form_field_manager property of the Editor class.
Properties
form_field_collection: Gets the collection of form fields in the document.
Methods
update_form_filed(…): Updates form fields in the document.
fix_invalid_form_field_names(…): Fixes invalid form field names in the document.
has_invalid_form_fields(): Checks if the document has invalid form fields.
get_invalid_form_field_names(): Returns the names of the invalid form fields in the document.
remove_form_fields(…): Removes form fields.
Conclusion
GroupDocs.Editor provides a powerful set of tools for managing form fields in Word documents. With these tools, developers can programmatically interact with, modify, and validate form fields, ensuring that documents are correctly formatted and free of duplicate or invalid form fields. For more details, refer to the official GroupDocs.Editor for Python via .NET documentation.