Skip to main content
All docs
V23.2

PdfAcroFormCheckBoxField.AddWidget(PdfRectangle) Method

Adds a widget annotation related to the check 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 check box with two widget annotations next to each other:

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
    checkBox.AddWidget( new PdfRectangle(310, 635, 330, 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