Class PdfButtonField
- Namespace
- Syncfusion.Pdf.Interactive
- Assembly
- Syncfusion.Pdf.Portable.dll
Represents button field in the PDF form.
public class PdfButtonField : PdfAppearanceField, INotifyPropertyChanged
- Inheritance
-
PdfButtonField
- Implements
- Inherited Members
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)
Remarks
This PdfButtonField class is used to add the button field to the PDF form. Please refer the UG docuemntation link
Constructors
PdfButtonField(PdfPageBase, string)
Initializes a new instance of the PdfButtonField class with the specific page and name.
public PdfButtonField(PdfPageBase page, string name)
Parameters
page
PdfPageBaseThe page where the fields should be placed.
name
stringThe 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
Properties
ComplexScript
Gets or sets the complex script language support.
public bool ComplexScript { get; set; }
Property Value
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)
- See Also
Text
Gets or sets the caption text.
public string Text { get; set; }
Property Value
- 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
Methods
AddPrintAction()
Adds Print action to current button field.
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
DrawAppearance(PdfTemplate)
Draws the appearance.
protected override void DrawAppearance(PdfTemplate template)
Parameters
template
PdfTemplateThe template.
- See Also
DrawPressedAppearance(PdfTemplate)
Draws the pressed appearance.
protected void DrawPressedAppearance(PdfTemplate template)
Parameters
template
PdfTemplateThe template.
- See Also
Initialize()
Initializes an instance.
protected override void Initialize()
- See Also