Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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.v24.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