DocumentBuilderInsertTextInput Method

Inserts a text form field at the current position.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public FormField InsertTextInput(
	string name,
	TextFormFieldType type,
	string format,
	string fieldValue,
	int maxLength


Type: SystemString
The name of the form field. Can be an empty string.
Type: Aspose.Words.FieldsTextFormFieldType
Specifies the type of the text form field.
Type: SystemString
Format string used to format the value of the form field.
Type: SystemString
Text that will be shown in the field.
Type: SystemInt32
Maximum length the user can enter into the form field. Set to zero for unlimited length.

Return Value

Type: FormField
The form field node that was just inserted.


If you specify a name for the form field, then a bookmark is automatically created with the same name.


Shows how to insert a text input form field into a document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertTextInput("TextInput", TextFormFieldType.Regular, "", "Hello", 0);
Shows how to insert form fields, set options and gather them back in for use.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a text input field. The unique name of this field is "TextInput1", the other parameters define
// what type of FormField it is, the format of the text, the field result and the maximum text length (0 = no limit)
builder.InsertTextInput("TextInput1", TextFormFieldType.Regular, "", "", 0);
Shows how to build a form field.
DocumentBuilder builder = new DocumentBuilder();

// Insert a text form field for input a name
builder.InsertTextInput("", TextFormFieldType.Regular, "", "Enter your name here", 30);

// Insert two blank lines

string[] items =
    "-- Select your favorite footwear --", "Sneakers", "Oxfords", "Flip-flops", "Other",
    "I prefer to be barefoot"

// Insert a combo box to select a footwear type
builder.InsertComboBox("", items, 0);

// Insert 2 blank lines

builder.Document.Save(ArtifactsDir + "DocumentBuilder.CreateForm.docx");

See Also