menu

Blazor

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

    Show / Hide Table of Contents

    Class ButtonField

    Represents a button field in the SfPdfViewer2 component.

    Inheritance
    System.Object
    FormFieldInfo
    ButtonField
    Inherited Members
    FormFieldInfo.BackgroundColor
    FormFieldInfo.BorderColor
    FormFieldInfo.Bounds
    FormFieldInfo.Color
    FormFieldInfo.CustomData
    FormFieldInfo.FontFamily
    FormFieldInfo.FontSize
    FormFieldInfo.FontStyle
    FormFieldInfo.Id
    FormFieldInfo.IsReadOnly
    FormFieldInfo.IsRequired
    FormFieldInfo.Name
    FormFieldInfo.PageNumber
    FormFieldInfo.TextAlignment
    FormFieldInfo.Thickness
    FormFieldInfo.TooltipText
    FormFieldInfo.Type
    FormFieldInfo.Visibility
    Namespace: Syncfusion.Blazor.SfPdfViewer
    Assembly: Syncfusion.Blazor.SfPdfViewer.dll
    Syntax
    public class ButtonField : FormFieldInfo
    Remarks

    The ButtonField class is used to define interactive button elements within a PDF Viewer. Button fields can be used to perform actions such as form submission, resetting form fields, or executing custom scripts.

    Examples

    The following example demonstrates how to create a button field:

    ButtonField buttonField = new ButtonField();
    buttonField.Name = "SubmitButton";
    buttonField.Text = "Submit"; // Sets the button text to "Submit"
    
    await viewer.AddFormFieldsAsync(new List<FormFieldInfo> { buttonField });

    Constructors

    ButtonField()

    Initializes a new instance of the ButtonField class in the SfPdfViewer2 component.

    Declaration
    public ButtonField()
    Remarks

    This constructor creates a button field with default settings, which can be used to perform interactive actions
    such as submitting forms, resetting fields, or triggering custom scripts within the PDF document. The default text alignment is Center to ensure button labels are properly aligned. The button field can be further customized with properties such as Name, IsRequired, and AppearanceSettings.

    Examples

    The following example demonstrates how to create a button field and assign its name:

    ButtonField buttonField = new ButtonField();
    buttonField.Name = "SubmitButton";
    buttonField.Text = "Submit"; // Sets the button text to "Submit"
    
    await viewer.AddFormFieldsAsync(new List<FormFieldInfo> { buttonField });

    Properties

    ImageSource

    Gets or sets the image source for the ButtonField in the SfPdfViewer2 component.

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

    A base64-encoded string representing the image data.

    Remarks

    This property accepts a base64-encoded string representing the image data. The image will be displayed over the button field text.

    Examples
    ButtonField buttonField = new ButtonField();
    buttonField.ImageSource = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...";

    Text

    Gets or sets the text displayed on the ButtonField in the SfPdfViewer2 component.

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

    A System.String representing the button's label text.

    Remarks

    This property specifies the label or caption displayed on the button field, which provides a visual indication
    of the button's purpose within the PDF form. If the button field is configured with an image appearance,
    the text will not be rendered.

    Examples

    The following example demonstrates how to set the text for the button field:

    ButtonField buttonField = new ButtonField();
    buttonField.Text = "Submit"; // Displays "Submit" as the button label.
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved