menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class FormFieldInfo - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class FormFieldInfo

    Provides detailed information and manages the properties for a form field within a PDF document presented in the SfPdfViewer2 component.

    Inheritance
    System.Object
    FormFieldInfo
    ButtonField
    CheckBoxField
    DropDownField
    ListBoxField
    PasswordField
    RadioButtonField
    SignatureField
    TextBoxField
    Namespace: Syncfusion.Blazor.SfPdfViewer
    Assembly: Syncfusion.Blazor.SfPdfViewer.dll
    Syntax
    public class FormFieldInfo : Object
    Remarks

    The FormFieldInfo class encapsulates various attributes necessary for defining form fields in a PDF, such as type, Name, PageNumber, and visual properties like Bounds, Color, and Visibility. This class is essential for custom form manipulation and rendering within the PDF viewer, offering control over the appearance and behavior of form fields.

    Examples

    Below is an example demonstrating how to initialize and set properties of the FormFieldInfo class:

    FormFieldInfo formField = new FormFieldInfo();
    formField.Name = "CustomerName";
    formField.Bounds = new Bound(){X = 100, Y = 150, Width = 200, Height = 50};
    formField.PageNumber = 1;

    Constructors

    FormFieldInfo()

    Declaration
    public FormFieldInfo()

    Properties

    BackgroundColor

    Gets or sets the background color of the form field in hexadecimal string format.

    Declaration
    public string BackgroundColor { get; set; }
    Property Value
    Type Description
    System.String

    The return type is string, representing the background color in hexadecimal format. A properly formatted hex code allows for precise color customization.

    Remarks

    The BackgroundColor property specifies the background color of the form field using a hexadecimal color code. This property enables customization of the form field's appearance, allowing users to highlight fields or maintain consistent design aesthetics. The hexadecimal string should follow the standard RGB or RGBA format (e.g., "#RRGGBB" or "#RRGGBBAA"). Invalid color codes may result in default rendering behavior.

    Examples

    The following example demonstrates how to set the BackgroundColor property for a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.BackgroundColor = "#FF5733"; // Sets the background color to orange.

    BorderColor

    Gets or sets the border color of the form field in hexadecimal string format.

    Declaration
    public string BorderColor { get; set; }
    Property Value
    Type Description
    System.String

    The return type is string, representing the border color in hexadecimal format. This format allows for precise color specification and supports transparency with RGBA codes.

    Remarks

    The BorderColor property specifies the border color of a form field using a hexadecimal string format. This property enables customization of the form field's appearance, helping to maintain visual consistency or highlight specific fields. The hexadecimal string should be in the standard RGB ("#RRGGBB") or RGBA ("#RRGGBBAA") format. If an invalid color code is provided, the background color will default to transparent.

    Examples

    The following example demonstrates how to set the BackgroundColor for a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.BackgroundColor = "#FF5733"; // Sets the background color to orange.

    Bounds

    Gets or sets the bounds of the form field in the PDF Viewer.

    Declaration
    public Bound Bounds { get; set; }
    Property Value
    Type Description
    Bound

    A Bound object representing the rectangle that defines the location and size of the form field in the PDF Viewer.

    Remarks

    The Bounds property specifies the location and size of the form field within the page of a PDF document displayed by the SfPdfViewer2 component. This property should be set with a valid rectangle area that corresponds to the desired position and size for the form field. The bounds are defined by a Bound object, which typically includes coordinates and dimensions.

    Examples

    The following example demonstrates how to set the Bounds for a form field:

    FormFieldInfo formField = new FormFieldInfo();
    formField.Bounds = new Bound(){X = 100, Y = 150, Width = 200, Height = 50};  // Sets the bounds of the form field

    Color

    Gets or sets the color of the form field in the PDF Viewer.

    Declaration
    public string Color { get; set; }
    Property Value
    Type Description
    System.String

    The color of the form field as a string. The default value is "Black". Acceptable values include named colors (e.g., "Red", "Blue") and hexadecimal codes (e.g., "#FF0000").

    Remarks

    The Color property defines the color of the form field's text depending on the field type. It is applicable for text-based form fields such as TextBox, ComboBox, Password, ButtonField, and ListBox This property does not apply to non-text fields like CheckBox, RadioButton, Signature fields. The color value must be specified as a string in a valid color format, such as named colors (e.g., "Red") or hexadecimal color codes (e.g., "#FF0000").

    Examples

    The following example demonstrates how to set the Color property for a text-based form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.Color = "Red"; // Sets the color to red

    CustomData

    Gets or sets custom data associated with the form field, allowing the storage of key-value pairs in dictionary format.

    Declaration
    public object CustomData { get; set; }
    Property Value
    Type Description
    System.Object

    The return type is object, allowing diverse data types to be stored as values while the dictionary keys remain strings. This provides flexibility to store custom information and metadata necessary for advanced form processing and validation.

    Remarks

    The CustomData property is used to associate custom metadata or additional information with a form field. This property accepts values in a dictionary format, where the keys are strings representing custom data labels, and the values can be of any object type. This flexibility allows developers to attach supplementary data such as user-defined attributes, configuration settings, or processing-related information to the form field.

    Examples

    The following example demonstrates how to assign custom dictionary values to the CustomData property:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.CustomData = new Dictionary<string, object>
    {
        { "Author", "John Doe" },
        { "Version", 1.0 },
        { "IsReviewed", true }
    };

    FontFamily

    Gets or sets the font family used for rendering text within a form field in the PDF Viewer.

    Declaration
    public string FontFamily { get; set; }
    Property Value
    Type Description
    System.String

    The font family of the form field text as a string. The default value is "Helvetica". Acceptable values include standard font families such as "Helvetica", "Times New Roman", and "Courier".

    Remarks

    The FontFamily property specifies the font style applied to the text content of the form field. The font name should be provided as a string and must correspond to a valid font available in the PDF viewer. Commonly supported fonts include "Helvetica", "Times New Roman", and "Courier".

    This property is applicable for text-based form fields such as TextBox, ComboBox, Password, ButtonField, and ListBox It does not apply to CheckBox, RadioButton fields and this property applies when a typed signature is used. The specified font family will be used to render the signature text.

    Examples

    The following example demonstrates how to set the FontFamily property:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.FontFamily = "Times New Roman"; // Sets the font family to Times New Roman

    FontSize

    Gets or sets the font size of the text in the form field.

    Declaration
    public double FontSize { get; set; }
    Property Value
    Type Description
    System.Double

    The font size of the text in the form field, measured in points. The default value is 10. Acceptable values are greater than 0.

    Remarks

    The FontSize property determines the size of the text displayed within the form field, measured in pixels. (px). It is applicable only to text-based form fields such as TextBox, ComboBox, Password, ButtonField, and ListBox This property does not apply to CheckBox, RadioButton, Signature fields. A larger value increases the text size, while a smaller value reduces it. Setting an appropriate size ensures optimal text visibility within the form field.

    Examples

    The following example demonstrates how to set the FontSize property:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.FontSize = 10; // Sets the font size to 10pt

    FontStyle

    Gets or sets the font style applied to the text content within a form field in the PDF document.

    Declaration
    public FontStyle FontStyle { get; set; }
    Property Value
    Type Description
    FontStyle

    The font style of the text in the form field, represented by the FontStyle enumeration. The default value is None.

    Remarks

    The FontStyle property determines the visual styling of the text content in the form field. It accepts one or more values from the FontStyle enumeration, which can be combined using bitwise OR operations (|).

    Available options include:

    • None: No special style applied.
    • Bold: Applies bold formatting.
    • Italic: Applies italic formatting.

    This property is applicable to text-based form fields such as TextBox, ComboBox, Password, ButtonField, and ListBox. It does not apply to CheckBox, RadioButton, Signature fields.

    Examples

    The following example demonstrates how to set multiple font styles:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.FontStyle = FontStyle.Bold | FontStyle.Italic; // Sets both bold and italic styles

    Id

    Gets the unique identifier of a form field in the PDF Viewer.

    Declaration
    public string Id { get; }
    Property Value
    Type Description
    System.String

    A System.String representing the unique identifier of the form field. This identifier is used to reference the field during programmatic interactions.

    Remarks

    The Id property uniquely identifies a form field within the PDF Viewer. This identifier is essential for distinguishing between fields and is particularly useful for programmatic interactions, enabling developers to target and manipulate specific fields.

    Examples

    The following example demonstrates how to retrieve the Id property of a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    string fieldId = formFieldInfo.Id; // Retrieves the form field's unique identifier.

    IsReadOnly

    Gets or sets a value indicating whether the form field is read-only in the PDF Viewer.

    Declaration
    public bool IsReadOnly { get; set; }
    Property Value
    Type Description
    System.Boolean

    A bool indicating the read-only state of the form field in the PDF Viewer; true if the field is read-only, otherwise false.

    Remarks

    The IsReadOnly property specifies whether the form field can be interacted with by the user within the PDF Viewer. When set to true, the form field is rendered as read-only, preventing any user modifications. This is useful for fields that should display information without allowing changes, ensuring data integrity. By default, this property is set to false, allowing user interaction with the form field.

    Examples

    Below is an example demonstrating how to set the IsReadOnly property:

    FormFieldInfo formField = new FormFieldInfo();
    formField.IsReadOnly = true;  // Sets the form field to be read-only

    IsRequired

    Gets or sets a value indicating whether the form field is required to be filled before exporting or downloading the PDF document.

    Declaration
    public bool IsRequired { get; set; }
    Property Value
    Type Description
    System.Boolean

    The return type is bool. A value of true indicates that the form field is mandatory, while false denotes the field is optional.

    Remarks

    The IsRequired property ensures that users fill out mandatory form fields before exporting or downloading the PDF document. This property is useful for enforcing validation rules in form-based workflows, where certain fields must contain data before further processing.

    Examples

    The following example demonstrates how to set the IsRequired property for a form field to ensure it is completed by the user:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.IsRequired = true;

    Name

    Gets or sets the name of the form field in the PDF Viewer.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the name in the form field.

    Remarks

    The Name property assigns a unique identifier to a form field in the PDF document displayed by the SfPdfViewer2 component. To prevent conflicts, ensure that this property is set with a unique name within the form.

    Examples

    The following example demonstrates how to assign a name to a form field:

    FormFieldInfo formField = new FormFieldInfo();
    formField.Name = "CustomName"; 

    PageNumber

    Gets or sets the page number of the form field in the PDF Viewer.

    Declaration
    public int PageNumber { get; set; }
    Property Value
    Type Description
    System.Int32

    An int representing the page number on which the form field is located within the PDF Viewer.

    Remarks

    The PageNumber property specifies the page number where the form field is located within the PDF document displayed by the SfPdfViewer2 component. Ensure this property is set with a valid page number that corresponds to the actual pages in the document for accurate positioning.

    Examples

    The following example demonstrates how to set the PageNumber for a form field:

    FormFieldInfo formField = new FormFieldInfo();
    formField.PageNumber = 3;

    TextAlignment

    Gets or sets the text alignment for a form field in the PDF Viewer.

    Declaration
    public TextAlignment TextAlignment { get; set; }
    Property Value
    Type Description
    TextAlignment

    The text alignment of the form field, represented by the TextAlignment enumeration. For ButtonField, the default text alignment is Center. For all other text-based form fields, the default alignment is Left The available alignment options are:

    • Left - Aligns text to the left.
    • Right - Aligns text to the right.
    • Center - Centers the text.
    Remarks

    The TextAlignment property specifies how the text content is aligned within the form field. This property is applicable only to text-based form fields, including TextBox, ComboBox, Password, ButtonField, and ListBox. It does not apply to non-text fields such as CheckBox, RadioButton, Signature fields.

    Examples

    The following example demonstrates how to set the TextAlignment property for a text-based form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.TextAlignment = TextAlignment.Center; // Sets the text alignment to center.

    Thickness

    Gets or sets the border thickness of the form field.

    Declaration
    public double Thickness { get; set; }
    Property Value
    Type Description
    System.Double

    The return type is int, representing the border thickness in device-independent pixels (DIP). A higher value results in a thicker border, making the form field more prominent.

    Remarks

    The Thickness property specifies the width of the border surrounding the form field in the PDF viewer. This property allows customization of the form field's appearance to highlight important fields or align with the design aesthetics of the form. Increasing the thickness enhances visibility, while smaller values provide a subtle appearance. Consider the overall layout and user interaction when setting this property to ensure a consistent and accessible user experience.

    Examples

    The following example demonstrates how to set the Thickness property for a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.Thickness = 2; 

    TooltipText

    Gets or sets the tooltip text that provides additional information about the form field.

    Declaration
    public string TooltipText { get; set; }
    Property Value
    Type Description
    System.String

    The return type is string, representing the tooltip text associated with the form field. This text is displayed when the user interacts with the form field.

    Remarks

    The TooltipText property defines a descriptive text that appears when users hover over the form field with the mouse or focus on it using the keyboard. This property helps convey guidance, instructions, or validation hints related to the form field's purpose, enhancing the overall user experience and accessibility of the form.

    Examples

    The following example demonstrates how to set the Tooltip property for a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.TooltipText = "Please enter your full name.";

    Type

    Gets or sets the type of the form field, specified using an enumeration.

    Declaration
    public FormFieldType Type { get; set; }
    Property Value
    Type Description
    FormFieldType

    The return type is FormFieldType, which represents the type of the form field. The available enumeration values include:

    • Textbox: Represents a text input field.
    • Password: Represents a password input field where text is masked.
    • CheckBox: Represents a checkbox control.
    • RadioButton: Represents a radio button control.
    • DropDown: Represents a dropdown selection field.
    • ListBox: Represents a list box selection field.
    • SignatureField: Represents a signature field.
    • Button: Represents a button control field.
    Remarks

    The Type property defines the type of the form field using the FormFieldType enumeration. This property allows specifying the field's role and expected input behavior, such as text input, password input, or interactive controls like checkboxes and dropdowns. Using the enumeration ensures type safety and simplifies the management of different form field types during form design.

    Examples

    The following example demonstrates how to set the Type property for a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.Type = FormFieldType.Textbox; // Sets the field type to a text box.

    Visibility

    Gets or sets the visibility of the form field in the PDF Viewer.

    Declaration
    public VisibilityMode Visibility { get; set; }
    Property Value
    Type Description
    VisibilityMode

    A VisibilityMode enumeration value that gets or sets the current visibility state of the form field in the PDF Viewer.

    Remarks

    The Visibility property determines whether the form field is visible, hidden, or visible only in print or screen modes.
    This property helps control user interactions and enhances the user experience based on dynamic conditions.
    Setting the appropriate visibility ensures that form fields appear only when needed, improving form layout and functionality.

    Examples

    The following example demonstrates how to set the visibility of a form field:

    FormFieldInfo formFieldInfo = new FormFieldInfo();
    formFieldInfo.Visibility = VisibilityMode.VisibleNotPrintable;
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved