officefileapi-120190-pdf-document-api-examples-interactive-form-how-to-obtain-a-checked-appearance-name-for-each-radio-button-in-the-radio-group.md
This code snippet gets a checked appearance name for each radio button and check the corresponding radio button with the obtained value.
using DevExpress.Pdf;
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");
}
Imports DevExpress.Pdf
Shared Sub Main(ByVal args() As String)
' Load a document with an interactive form.
Dim processor As New PdfDocumentProcessor()
processor.LoadDocument("DocumentToFill.pdf")
' Retrieve the form field facade:
Dim documentFacade As PdfDocumentFacade = processor.DocumentFacade
Dim acroFormFacade As PdfAcroFormFacade = documentFacade.AcroForm
' Specify a checked appearance name for the Female radio button:
Dim genderField As PdfRadioGroupFormFieldFacade = acroFormFacade.GetRadioGroupFormField("Gender")
For Each item As PdfFormFieldItem In genderField.Field.Items
If item.Value = "Female" Then
genderField.Value = item.Value
End If
Next item
' Save the modified document.
processor.SaveDocument("..\..\Result.pdf")
End Sub