Skip to main content
All docs
V23.2

PdfAcroFormRadioGroupField.AddButton(String, Int32, PdfRectangle) Method

Adds a radio button to the radio group field. Allows you to specify a page where the button should be located.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

Declaration

public void AddButton(
    string name,
    int pageNumber,
    PdfRectangle rect
)

Parameters

Name Type Description
name String

The name of a radio button.

pageNumber Int32

The number of the page where the radio button should be located.

rect PdfRectangle

A page area where the radio button should be located.

Remarks

Tip

Add buttons with the same name on different pages so they are selected and unselected simultaneously.

The code sample below creates a radio group form field with four buttons - two on the first page, and two on the second page:

button

using DevExpress.Pdf;

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

    // Create a radio group field
    PdfAcroFormRadioGroupField radioGroup =
       new PdfAcroFormRadioGroupField("Contact Group", 1);

    // Add the first radio button to the group
    radioGroup.AddButton("button1", new PdfRectangle(230, 635, 250, 655));

    // Add the same radio button on the second page
    radioGroup.AddButton("button1", 2, new PdfRectangle(230, 635, 250, 655));

    // Add the second radio button to the group
    radioGroup.AddButton("button2", new PdfRectangle(310, 635, 330, 655));

    // Add the same button on the second page
    radioGroup.AddButton("button2", 2, new PdfRectangle(310, 635, 330, 655));

    // Specify radio group selected index and appearance
    radioGroup.SelectedIndex = 0;
    radioGroup.Appearance.BorderAppearance = new PdfAcroFormBorderAppearance() 
    { 
        Color = new PdfRGBColor(0.8, 0.5, 0.3), 
        Width = 3 
    };

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

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