menu

Document Processing

PdfButtonField Class - C# PDF Library API Reference | Syncfusion

    Show / Hide Table of Contents

    PdfButtonField Class

    Represents button field in the PDF form.

    Inheritance
    System.Object
    PdfField
    PdfStyledField
    PdfAppearanceField
    PdfButtonField
    Implements
    System.ComponentModel.INotifyPropertyChanged
    Inherited Members
    PdfAppearanceField.Appearance
    PdfField.DisableAutoFormat
    PdfField.Export
    PdfField.Flatten
    PdfField.Form
    PdfField.GetValue(String)
    PdfField.Layer
    PdfField.MappingName
    PdfField.Name
    PdfField.Page
    PdfField.PdfTag
    PdfField.PropertyChanged
    PdfField.ReadOnly
    PdfField.Required
    PdfField.SetValue(String, String)
    PdfField.TabIndex
    PdfField.ToolTip
    PdfStyledField.Actions
    PdfStyledField.BackColor
    PdfStyledField.BorderColor
    PdfStyledField.BorderStyle
    PdfStyledField.BorderWidth
    PdfStyledField.Bounds
    PdfStyledField.DefineDefaultAppearance()
    PdfStyledField.Font
    PdfStyledField.ForeColor
    PdfStyledField.HighlightMode
    PdfStyledField.Location
    PdfStyledField.ObtainFont()
    PdfStyledField.RotationAngle
    PdfStyledField.Size
    PdfStyledField.TextAlignment
    PdfStyledField.Visibility
    PdfStyledField.Visible
    Namespace: Syncfusion.Pdf.Interactive
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public class PdfButtonField : PdfAppearanceField, IPdfWrapper, INotifyPropertyChanged
    Remarks

    This PdfButtonField class is used to add the button field to the PDF form. Please refer the UG docuemntation link https://help.syncfusion.com/file-formats/pdf/working-with-forms#adding-the-button-field for more details.

    Examples
    //Create a new PDf document
    PdfDocument document = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = document.Pages.Add();
    PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
    PdfBrush brush = PdfBrushes.Black;
    PdfGraphics graphics = page.Graphics;
    // Creating action
    PdfSubmitAction submitAction = new PdfSubmitAction("http://stevex.net/dump.php");
    submitAction.DataFormat = SubmitDataFormat.Html;
    //Create submit button to transfer the values in the form
    PdfButtonField submitButton = new PdfButtonField(page, "submitButton");
    submitButton.Bounds = new RectangleF(100, 500, 90, 20);
    submitButton.Font = font;
    submitButton.Text = "Submit";
    submitButton.Actions.MouseUp = submitAction;
    document.Form.Fields.Add(submitButton);
    document.Save("Form.pdf");
    document.Close(true);
    'Create a new PDf document
    Dim document As PdfDocument = New PdfDocument()
    'Create a page
    Dim page As PdfPage = document.Pages.Add()
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
    Dim brush As PdfBrush = PdfBrushes.Black
    Dim graphics As PdfGraphics = page.Graphics
    ' Creating action
    Dim submitAction As PdfSubmitAction = New PdfSubmitAction("http://stevex.net/dump.php")
    submitAction.DataFormat = SubmitDataFormat.Html
    'Create submit button to transfer the values in the form
    Dim submitButton As PdfButtonField = New PdfButtonField(page, "submitButton")
    submitButton.Bounds = New RectangleF(100, 500, 90, 20)
    submitButton.Font = font
    submitButton.Text = "Submit"
    submitButton.Actions.MouseUp = submitAction
    document.Form.Fields.Add(submitButton)
    document.Save("Form.pdf")
    document.Close(True)

    Constructors

    PdfButtonField(PdfPageBase, String)

    Initializes a new instance of the PdfButtonField class with the specific page and name.

    Declaration
    public PdfButtonField(PdfPageBase page, string name)
    Parameters
    Type Name Description
    PdfPageBase page

    The page where the fields should be placed.

    System.String name

    The name of the button.

    Examples
    //Create a new PDf document
    PdfDocument document = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = document.Pages.Add();
    PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
    PdfBrush brush = PdfBrushes.Black;
    PdfGraphics graphics = page.Graphics;
    // Creating action
    PdfSubmitAction submitAction = new PdfSubmitAction("http://stevex.net/dump.php");
    submitAction.DataFormat = SubmitDataFormat.Html;
    //Create submit button to transfer the values in the form
    PdfButtonField submitButton = new PdfButtonField(page, "submitButton");
    submitButton.Bounds = new RectangleF(100, 500, 90, 20);
    submitButton.Font = font;
    submitButton.Text = "Submit";
    submitButton.Actions.MouseUp = submitAction;
    document.Form.Fields.Add(submitButton);
    document.Save("Form.pdf");
    document.Close(true);
    'Create a new PDf document
    Dim document As PdfDocument = New PdfDocument()
    'Create a page
    Dim page As PdfPage = document.Pages.Add()
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
    Dim brush As PdfBrush = PdfBrushes.Black
    Dim graphics As PdfGraphics = page.Graphics
    ' Creating action
    Dim submitAction As PdfSubmitAction = New PdfSubmitAction("http://stevex.net/dump.php")
    submitAction.DataFormat = SubmitDataFormat.Html
    'Create submit button to transfer the values in the form
    Dim submitButton As PdfButtonField = New PdfButtonField(page, "submitButton")
    submitButton.Bounds = New RectangleF(100, 500, 90, 20)
    submitButton.Font = font
    submitButton.Text = "Submit"
    submitButton.Actions.MouseUp = submitAction
    document.Form.Fields.Add(submitButton)
    document.Save("Form.pdf")
    document.Close(True)
    See Also
    PdfAppearanceField
    PdfDocument
    PdfSubmitAction

    Properties

    ComplexScript

    Gets or sets the complex script language support.

    Declaration
    public bool ComplexScript { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
    //Create a new PDF document.
    PdfDocument document = new PdfDocument();
    //Add a new PDF page.
    PdfPage page = document.Pages.Add();
    //Create font.
    Font font = new Font("Tahoma", 10f);
    //Create a new PDF font instance.
    PdfFont pdfFont = new PdfTrueTypeFont(font, FontStyle.Regular, 10f, true, true);
    //Create a new button field.
    PdfButtonField buttonField = new PdfButtonField(page, "Click");
    //Set bounds
    buttonField.Bounds = new RectangleF(0, 0, 300, 20);
    //Set font.
    buttonField.Font = pdfFont;
    //Set text.
    buttonField.Text = "เสนอ";
    //Enable complex script.
    buttonField.ComplexScript = true;
    //Add field to form.
    document.Form.Fields.Add(buttonField);
    document.Form.SetDefaultAppearance(false);
    //Save the document.
    document.Save("output.pdf");
    //Close the document.
    document.Close(true);
    'Create a new PDF document.
    Dim document As New PdfDocument()
    'Add a new PDF page.
    Dim page As PdfPage = document.Pages.Add()
    'Create font.
    Dim font As New Font("Tahoma", 10F)
    'Create a new PDF font instance.
    Dim pdfFont As PdfFont = New PdfTrueTypeFont(font, FontStyle.Regular, 10F, True, True)
    'Create a new button field.
    Dim buttonField As New PdfButtonField(page, "Click")
    'Set bounds
    buttonField.Bounds = New RectangleF(0, 0, 300, 20)
    'Set font.
    buttonField.Font = pdfFont
    'Set text.
    buttonField.Text = "เสนอ"
    'Enable complex script.
    buttonField.ComplexScript = True
    'Add field to form.
    document.Form.Fields.Add(buttonField)
    document.Form.SetDefaultAppearance(False)
    'Save the document.
    document.Save("output.pdf")
    'Close the document.
    document.Close(True)

    Text

    Gets or sets the caption text.

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

    The caption text.

    Examples
    //Create a new PDf document
    PdfDocument document = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = document.Pages.Add();
    PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
    PdfBrush brush = PdfBrushes.Black;
    PdfGraphics graphics = page.Graphics;
    // Creating action
    PdfSubmitAction submitAction = new PdfSubmitAction("http://stevex.net/dump.php");
    submitAction.DataFormat = SubmitDataFormat.Html;
    //Create submit button to transfer the values in the form
    PdfButtonField submitButton = new PdfButtonField(page, "submitButton");
    submitButton.Bounds = new RectangleF(100, 500, 90, 20);
    submitButton.Font = font;
    submitButton.Text = "Submit";
    submitButton.Actions.MouseUp = submitAction;
    document.Form.Fields.Add(submitButton);
    document.Save("Form.pdf");
    document.Close(true);
    'Create a new PDf document
    Dim document As PdfDocument = New PdfDocument()
    'Create a page
    Dim page As PdfPage = document.Pages.Add()
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
    Dim brush As PdfBrush = PdfBrushes.Black
    Dim graphics As PdfGraphics = page.Graphics
    ' Creating action
    Dim submitAction As PdfSubmitAction = New PdfSubmitAction("http://stevex.net/dump.php")
    submitAction.DataFormat = SubmitDataFormat.Html
    'Create submit button to transfer the values in the form
    Dim submitButton As PdfButtonField = New PdfButtonField(page, "submitButton")
    submitButton.Bounds = New RectangleF(100, 500, 90, 20)
    submitButton.Font = font
    submitButton.Text = "Submit"
    submitButton.Actions.MouseUp = submitAction
    document.Form.Fields.Add(submitButton)
    document.Save("Form.pdf")
    document.Close(True)
    See Also
    PdfDocument
    PdfSubmitAction

    Methods

    AddPrintAction()

    Adds Print action to current button field. Clicking on the specified button will trigger the Print Dialog Box.

    Declaration
    public void AddPrintAction()
    Examples
    //Create a new PDf document
    PdfDocument document = new PdfDocument();
    //Creates a new page and adds it as the last page of the document
    PdfPage page = document.Pages.Add();
    PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12f);
    PdfBrush brush = PdfBrushes.Black;
    PdfGraphics graphics = page.Graphics;
    // Creating action
    PdfSubmitAction submitAction = new PdfSubmitAction("http://stevex.net/dump.php");
    submitAction.DataFormat = SubmitDataFormat.Html;
    //Create submit button to transfer the values in the form
    PdfButtonField submitButton = new PdfButtonField(page, "submitButton");
    submitButton.Bounds = new RectangleF(100, 500, 90, 20);
    submitButton.Font = font;
    submitButton.Text = "Submit";
    // Subscribing print action
    submitButton.AddPrintAction();
    submitButton.Actions.MouseUp = submitAction;
    document.Form.Fields.Add(submitButton);
    document.Save("Form.pdf");
    document.Close(true);
    'Create a new PDf document
    Dim document As PdfDocument = New PdfDocument()
    'Create a page
    Dim page As PdfPage = document.Pages.Add()
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12f)
    Dim brush As PdfBrush = PdfBrushes.Black
    Dim graphics As PdfGraphics = page.Graphics
    ' Creating action
    Dim submitAction As PdfSubmitAction = New PdfSubmitAction("http://stevex.net/dump.php")
    submitAction.DataFormat = SubmitDataFormat.Html
    'Create submit button to transfer the values in the form
    Dim submitButton As PdfButtonField = New PdfButtonField(page, "submitButton")
    submitButton.Bounds = New RectangleF(100, 500, 90, 20)
    submitButton.Font = font
    submitButton.Text = "Submit"
    ' Subscribing print action
    submitButton.AddPrintAction()
    submitButton.Actions.MouseUp = submitAction
    document.Form.Fields.Add(submitButton)
    document.Save("Form.pdf")
    document.Close(True)
    See Also
    PdfAppearanceField
    PdfDocument
    PdfSubmitAction

    DrawAppearance(PdfTemplate)

    Draws the appearance.

    Declaration
    protected override void DrawAppearance(PdfTemplate template)
    Parameters
    Type Name Description
    PdfTemplate template

    The template.

    Overrides
    PdfAppearanceField.DrawAppearance(PdfTemplate)

    DrawPressedAppearance(PdfTemplate)

    Draws the pressed appearance.

    Declaration
    protected void DrawPressedAppearance(PdfTemplate template)
    Parameters
    Type Name Description
    PdfTemplate template

    The template.

    Initialize()

    Initializes an instance.

    Declaration
    protected override void Initialize()
    Overrides
    PdfStyledField.Initialize()

    Implements

    System.ComponentModel.INotifyPropertyChanged

    See Also

    PdfAppearanceField
    PdfDocument
    PdfSubmitAction
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved