Skip to main content

How to: Obtain a Checked Appearance Name for Each Radio Button in the Radio Group

This example shows how to get a checked appearance name for each radio button and check the corresponding radio button with the obtained value.

View Example

static void Main(string[] args)
{
    // Load a document with an interactive form.
    PdfDocumentProcessor processor = new PdfDocumentProcessor();
    processor.LoadDocument(@"DocumentToFill.pdf");

    // Retrieve the form field facade:
    PdfDocumentFacade documentFacade = processor.DocumentFacade;
    PdfAcroFormFacade acroFormFacade = documentFacade.AcroForm;

    // Specify a checked appearance name for the Female radio button:
    PdfRadioGroupFormFieldFacade genderField = acroFormFacade.GetRadioGroupFormField("Gender");
    foreach (PdfFormFieldItem item in genderField.Field.Items)
    {
        if (item.Value == "Female")
            genderField.Value = item.Value;
    }

    // Save the modified document.
    processor.SaveDocument("..\\..\\Result.pdf");
}