Skip to main content
All docs
V23.2

PdfAcroFormTextBoxField.AddWidget(Int32, PdfRectangle) Method

Adds a widget annotation related to the text 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 text 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 text box field on the first page
  PdfAcroFormTextBoxField textBox =
      new PdfAcroFormTextBoxField("text box", 1, new PdfRectangle(230, 690, 280, 710));

  // Specify text box text and appearance
  textBox.Text = "Text Box";
  textBox.Appearance.BackgroundColor = new PdfRGBColor(0.8, 0.5, 0.3);
  textBox.Appearance.FontSize = 12;

  // Add a text box widget on the second page
  textBox.AddWidget(2, new PdfRectangle(230, 690, 280, 710));

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

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