ResetFormAction
RadPdfProcessing provides functionality for resetting the form fields (introduced in Q1 2025). The ResetFormAction class represents an action that resets specific form fields in a document. The Fields property represents the list of field names that are included in the reset operation or excluded from it.
The ResetFormType property represents the type of the reset form behavior. The available options are:
Include: Specifies that the reset form should include the specified form fields.
Exclude: Specifies that the reset form should exclude the specified form fields.
Creating a PushButtonWidget with a ResetFormAction
The following example demonstrates how to create a document from scratch, add a form field (e.g. CheckBoxField), and a push-button which is expected to trigger the reset action for the checkbox when the button is clicked.
RadFixedDocument fixedDocument = new RadFixedDocument();
RadFixedPage fixedPage = fixedDocument.Pages.AddPage();
string fieldName = "SampleCheckBox";
CheckBoxField checkBoxField = new CheckBoxField(fieldName);
checkBoxField.IsChecked = true;
TwoStatesButtonWidget CheckBoxWidget = checkBoxField.Widgets.AddWidget();
CheckBoxWidget.Rect = new Rect(200, 200, 20, 20);
fixedDocument.AcroForm.FormFields.Add(checkBoxField);
fixedDocument.Pages[0].Annotations.Add(CheckBoxWidget);
PushButtonField pushButtonFieldReset = new PushButtonField("SamplePushButton");
PushButtonWidget buttonWidgetReset = pushButtonFieldReset.Widgets.AddWidget();
buttonWidgetReset.Rect = new Rect(0, 0, 250, 50);
buttonWidgetReset.HighlightingMode = HighlightingMode.InvertBorderOfAnnotationRectangle;
ResetFormAction resetFormAction = new ResetFormAction(new List<string>() { fieldName }, ResetFormType.Include);
buttonWidgetReset.Actions.MouseUp.Add(resetFormAction);
buttonWidgetReset.AppearanceCharacteristics.Background = new RgbColor(123, 165, 134);
buttonWidgetReset.AppearanceCharacteristics.NormalCaption = "Reset";
buttonWidgetReset.TextProperties.FontSize = 20;
buttonWidgetReset.TextProperties.Fill = new RgbColor(0, 0, 0);
buttonWidgetReset.RecalculateContent();
fixedDocument.AcroForm.FormFields.Add(pushButtonFieldReset);
fixedDocument.Pages[0].Annotations.Add(buttonWidgetReset);
Updating an Existing document with a field
If the document already contains form fields and a PushButtonWidget, it is possible to access the existing button and add the ResetFormAction.
PushButtonWidget resetPushButtonWidget = ((PushButtonField)fixedDocument.AcroForm.FormFields.Last()).Widgets.First();
ResetFormAction resetAction = resetPushButtonWidget.Actions.MouseUp.First() as ResetFormAction;
string fieldNameToReset = fixedDocument.AcroForm.FormFields.First().Name;
resetAction.Fields.Add(fieldNameToReset);
resetAction.ResetFormType = ResetFormType.Include;