Class TextBoxField
Represents a text box field in the SfPdfViewer2 component.
Inherited Members
Namespace: Syncfusion.Blazor.SfPdfViewer
Assembly: Syncfusion.Blazor.SfPdfViewer.dll
Syntax
public class TextBoxField : FormFieldInfo
Remarks
Initializes a new instance of the TextBoxField class with the default field type set to "TextBox."
This allows users to input text in interactive PDF forms.
Examples
TextBoxField textBoxField = new TextBoxField();
textBoxField.Name = "UserName";
textBoxField.Value = "Enter your name";
await viewer.AddFormFieldsAsync(new List<FormFieldInfo> { textBoxField });
Constructors
TextBoxField()
Initializes a new instance of the TextBoxField class.
Declaration
public TextBoxField()
Remarks
This constructor creates a text box field with the default field type set to "TextBox."
It can be added to a PDF form to allow user text input.
Examples
TextBoxField textBoxField = new TextBoxField();
textBoxField.Name = "UserName";
textBoxField.Value = "Enter your name";
await viewer.AddFormFieldsAsync(new List<FormFieldInfo> { textBoxField });
Properties
InsertSpaces
Gets or sets a value indicating whether spaces are automatically inserted between characters in the TextBoxField of the SfPdfViewer2 component.
Declaration
public bool InsertSpaces { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean indicating whether spaces are automatically inserted between characters in the TextBoxField. |
Remarks
When InsertSpaces is set to true, spaces are added between each character as the user types. If InsertSpaces is set to false, text is entered normally without additional spaces.
Examples
TextBoxField textBoxField = new TextBoxField();
textBoxField.InsertSpaces = true; // Enables automatic space insertion
IsMultiline
Gets or sets a value indicating whether the IsMultiline property allows multiple lines of text in the SfPdfViewer2 component.
Declaration
public bool IsMultiline { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean indicating whether the TextBoxField supports multiple lines of text. |
Remarks
When IsMultiline is set to true, the TextBoxField supports multiple lines of text input. If IsMultiline is set to false, the text box allows only a single line of text.
Examples
TextBoxField textBoxField = new TextBoxField();
textBoxField.IsMultiline = true;
MaxLength
Gets or sets the maximum number of characters allowed in the TextBoxField of the SfPdfViewer2 component.
Declaration
public int MaxLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | A System.Int32 representing the maximum number of characters allowed. The default value is 0. |
Remarks
Specifies the upper limit for user input in the TextBoxField. When this property is set, the field restricts user input to the specified character limit. Setting the value to 0 or a negative number means no limit is applied. This property is useful for ensuring that user input does not exceed the desired length for validation or formatting purposes.
Examples
TextBoxField textBoxField = new TextBoxField();
textBoxField.MaxLength = 100; // Restricts input to 100 characters.
Value
Gets or sets the text content of the TextBoxField in the SfPdfViewer2 component.
Declaration
public string Value { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.String representing the text content of the TextBoxField. |
Remarks
Represents the user-entered or pre-filled text in the TextBoxField. Changing this property updates the displayed text in the corresponding PDF form field.
Examples
TextBoxField textBoxField = new TextBoxField();
textBoxField.Value = "Enter your name";