officefileapi-devexpress-dot-pdf-dot-pdfinteractiveform-dot-getformfield-x28-system-dot-string-x29.md
Obtains the interactive form field by its name.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public PdfInteractiveFormField GetFormField(
string name
)
Public Function GetFormField(
name As String
) As PdfInteractiveFormField
| Name | Type | Description |
|---|---|---|
| name | String |
The form field name.
|
| Type | Description |
|---|---|
| PdfInteractiveFormField |
An interactive from field with the specified name.
|
The code sample below retrieves form fields by name and changes their properties:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
pdfDocumentProcessor.LoadDocument("FormDemo.pdf");
ChangeFormFields(pdfDocumentProcessor);
pdfDocumentProcessor.SaveDocument("FormDemo.pdf");
Process.Start(new ProcessStartInfo("FormDemo.pdf")
{ UseShellExecute = true });
}
private static void ChangeFormFields(PdfDocumentProcessor pdfDocumentProcessor)
{
PdfInteractiveForm acroForm = pdfDocumentProcessor.Document.AcroForm;
//Change radio group field properties:
PdfButtonFormField genderFormField = (PdfButtonFormField)acroForm.GetFormField("Gender");
genderFormField.ToggleToOff = true;
//Change text field properties:
PdfTextFormField addressFormField = (PdfTextFormField)acroForm.GetFormField("Address");
addressFormField.Multiline = false;
addressFormField.InputType = PdfTextFieldInputType.PlainText;
//Change combo box field properties:
PdfChoiceFormField nationalityFormField = (PdfChoiceFormField)acroForm.GetFormField("Nationality");
nationalityFormField.Editable = false;
nationalityFormField.MultiSelect = false;
}
Using pdfDocumentProcessor As New PdfDocumentProcessor()
pdfDocumentProcessor.LoadDocument("FormDemo.pdf")
ChangeFormFields(pdfDocumentProcessor)
pdfDocumentProcessor.SaveDocument("FormDemo.pdf")
Process.Start(New ProcessStartInfo("FormDemo.pdf") With {.UseShellExecute = True})
End Using
private static void ChangeFormFields(PdfDocumentProcessor pdfDocumentProcessor)
Dim acroForm As PdfInteractiveForm = pdfDocumentProcessor.Document.AcroForm
'Change radio group field properties:
Dim genderFormField As PdfButtonFormField = CType(acroForm.GetFormField("Gender"), PdfButtonFormField)
genderFormField.ToggleToOff = True
'Change text field properties:
Dim addressFormField As PdfTextFormField = CType(acroForm.GetFormField("Address"), PdfTextFormField)
addressFormField.Multiline = False
addressFormField.InputType = PdfTextFieldInputType.PlainText
'Change combo box field properties:
Dim nationalityFormField As PdfChoiceFormField = CType(acroForm.GetFormField("Nationality"), PdfChoiceFormField)
nationalityFormField.Editable = False
nationalityFormField.MultiSelect = False
End Sub
See Also