PdfButtonWidgetFacade Class
Contains properties used to change the button field’s widget annotation without access to its inner structure.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.1.Core.dll
NuGet Package: DevExpress.Pdf.Core
Declaration
Remarks
Use the Widgets property to get options of each widget annotation associated with the button form field. The PdfButtonWidgetFacade
class properties allow you to change the border and background color, specify alternate caption and more.
The code sample below changes the button form field appearance:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
pdfDocumentProcessor.LoadDocument("Documents//FormDemo.pdf");
PdfDocumentFacade documentFacade = pdfDocumentProcessor.DocumentFacade;
PdfAcroFormFacade acroForm = documentFacade.AcroForm;
//Obtain button form field parameters:
PdfButtonFormFieldFacade pushButton = acroForm.GetButtonFormField("Submit");
//Retrieve form field widget:
PdfButtonWidgetFacade buttonWidget = pushButton.Widgets[0];
//Change widget's color options:
buttonWidget.BorderWidth = 1;
buttonWidget.BackgroundColor = new PdfRGBColor(0.81, 0.81, 0.81);
buttonWidget.BorderColor = new PdfRGBColor(0.47, 0.44, 0.67);
buttonWidget.FontColor = new PdfRGBColor(0.34, 0.25, 0.36);
}
Change Icon Options
Use the following methods to specify a button icon:
- PdfButtonWidgetFacade.SetNormalIcon - Specifies an icon displayed when the button is not clicked.
- PdfButtonWidgetFacade.SetAlternateIcon - Specifies an icon displayed when the user clicks the button, but before the button is released.
- PdfButtonWidgetFacade.SetRolloverIcon - Specifies an icon displayed when the mouse pointer hovers over the button.
The PdfButtonWidgetIconOptions class properties allow you to specify icon display and scale options. Use the PdfButtonWidgetFacade.IconOptions property to get these options.
The code sample below specifies a normal icon and its options:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
pdfDocumentProcessor.LoadDocument("Documents//FormDemo.pdf");
PdfDocumentFacade documentFacade = pdfDocumentProcessor.DocumentFacade;
PdfAcroFormFacade acroForm = documentFacade.AcroForm;
//Change all form fields' color settings:
var fields = acroForm.GetFields();
foreach (PdfFormFieldFacade field in fields)
{
ChangeFormFieldColor(field);
}
//Obtain button form field parameters:
PdfButtonFormFieldFacade pushButton = acroForm.GetButtonFormField("Submit");
PdfButtonWidgetFacade buttonWidget = pushButton.Widgets[0];
//Specify a button icon and set its options:
buttonWidget.SetNormalIcon("Documents//submit_3802014.png");
buttonWidget.IconOptions.FitToAnnotationBounds = true;
buttonWidget.IconOptions.ScaleCondition = PdfIconScalingCircumstances.BiggerThanAnnotationRectangle;
buttonWidget.TextPosition = PdfWidgetAnnotationTextPosition.NoCaption;
}