Skip to main content
All docs
V23.2

PdfAcroFormChoiceField.AddWidget(PdfRectangle) Method

Adds a widget annotation related to the choice form field (combo box or list box). The widget is added to the page where the form field is located.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v23.2.Core.dll

NuGet Package: DevExpress.Pdf.Core

Declaration

public void AddWidget(
    PdfRectangle rectangle
)

Parameters

Name Type Description
rectangle PdfRectangle

The page rectangle where the widget annotation should be added.

Remarks

A widget annotation contains form field display properties. One field can be related to multiple widget annotations. When you create a form field, the widget annotation is created automatically. Call the AddWidget method to create an additional widget on the same page with the form field.

The code sample below creates a list box with two widget annotations, one below another:

widgets

using DevExpress.Pdf;
using System.Globalization;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
  // Load a document
  processor.LoadDocument("..\\..\\Document.pdf");

  // Add a list box field on the first page
  PdfAcroFormListBoxField listBox =
     new PdfAcroFormListBoxField("Language", 1, new PdfRectangle(230, 595, 330, 615));

  // Specify list box color and font size
  listBox.Appearance.BackgroundColor = new PdfRGBColor(0.8, 0.5, 0.3);
  listBox.Appearance.FontSize = 12;

  // Add values to the list box
  var allCultures = CultureInfo.GetCultures(CultureTypes.NeutralCultures);
  foreach (var item in allCultures)
  {
      if (item!= null)
      {
          listBox.AddValue(item.DisplayName);
      }
  }
  listBox.MultiSelect = false;

  // Add a widget annotation
  listBox.AddWidget(new PdfRectangle(230, 555, 330, 575));

  // Add a form field
  processor.AddFormFields(listBox);

  // Save the result
  processor.SaveDocument("..\\..\\Result.pdf");
}
See Also