Skip to main content
All docs
V23.2

PdfAcroFormCheckBoxField.AddWidget(Int32, PdfRectangle) Method

Adds a widget annotation related to the check box. Allows you to specify a page to which the widget should be added.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

Declaration

public void AddWidget(
    int pageNumber,
    PdfRectangle rectangle
)

Parameters

Name Type Description
pageNumber Int32

The number of a page to which to add the widget annotation (starting with 1).

rectangle PdfRectangle

The page rectangle where to add the widget annotation.

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 and pass the page number as the method parameter to create an additional widget on a separate page.

The code sample below creates a check box with two widget annotations on the first and second pages:

widgets

using DevExpress.Pdf;

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

    // Create a check box field
    PdfAcroFormCheckBoxField checkBox =
        new PdfAcroFormCheckBoxField("Gender", 1, new PdfRectangle(230, 635, 250, 655));

    // Add a widget annotation on the second page
    checkBox.AddWidget(2, new PdfRectangle(230, 635, 250, 655));

    // Specify check box state and appearance
    checkBox.IsChecked = false;
    checkBox.Appearance.BorderAppearance = new PdfAcroFormBorderAppearance()
    {
        Color = new PdfRGBColor(0.8, 0.5, 0.3),
        Width = 3
    };

    // Add a form field to the page
    processor.AddFormFields(checkBox);

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