This article describes the following topics:
This class corresponds to FormFieldType.PushButton enum value and represents a simple button that may be clicked with the mouse. This is the only field that does not preserve any data. It is usually used to execute some action on mouse click such as the action for submitting the form data.
PushButtonField provides a single property called Widgets. It represents the collection of Widget annotations, which visualize the field on the PDF pages. The widgets can be added and removed from the collection using the collection's AddWidget() and Remove() methods respectively. As the widget collection implements the IEnumerable interface, the available widget instances can be iterated.
Example 1: Create a PushButtonField and add it to a page
PushButtonField pushButtonField = new PushButtonField("SamplePushButton"); PushButtonWidget widget = pushButtonField.Widgets.AddWidget(); widget.Rect = new Rect(new Size(250, 50)); widget.HighlightingMode = HighlightingMode.InvertBorderOfAnnotationRectangle; widget.AppearanceCharacteristics.Background = new RgbColor(123, 165, 134); widget.AppearanceCharacteristics.NormalCaption = "Click here"; widget.TextProperties.FontSize = 20; widget.TextProperties.Fill = new RgbColor(0, 0, 0); widget.RecalculateContent(); document.AcroForm.FormFields.Add(pushButtonField); document.Pages.Annotations.Add(widget);