FindField(String) Метод (PdfDocumentInteractiveForm)
Находит поле по указанному полностью определенному имени поля.
Parameters
- fullyQualifiedFieldName
- Полное имя поля.
Return Value
Экземпляр объекта
PdfInteractiveFormField, если поле найдено; в противном случае
null.
Вот пример, показывающий, как найти поле с указанным именем и изменить значение поля:
''' <summary>
''' Changes the text field value.
''' </summary>
''' <param name="document">The PDF document.</param>
''' <param name="fieldFullName">Full name of the field.</param>
''' <param name="newValue">The new value of the field.</param>
''' <returns>
''' <b>true</b> - field value is changed successfully;
''' <b>false</b> - field value is NOT changed.
''' </returns>
Public Shared Function ChangeTextFieldValue(document As Vintasoft.Imaging.Pdf.PdfDocument, fieldFullName As String, newValue As String) As Boolean
' if PDF document has PDF interactive form
If document.InteractiveForm IsNot Nothing Then
' find field by name
Dim field As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField = document.InteractiveForm.FindField(fieldFullName)
' if field is found
If field IsNot Nothing Then
Dim textField As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormTextField = TryCast(field, Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormTextField)
' if field is text field
If textField IsNot Nothing Then
' set new value of the field
textField.Value = New Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormTextFieldStringValue(document, newValue)
Return True
End If
End If
End If
Return False
End Function
/// <summary>
/// Changes the text field value.
/// </summary>
/// <param name="document">The PDF document.</param>
/// <param name="fieldFullName">Full name of the field.</param>
/// <param name="newValue">The new value of the field.</param>
/// <returns>
/// <b>true</b> - field value is changed successfully;
/// <b>false</b> - field value is NOT changed.
/// </returns>
public static bool ChangeTextFieldValue(
Vintasoft.Imaging.Pdf.PdfDocument document,
string fieldFullName,
string newValue)
{
// if PDF document has PDF interactive form
if (document.InteractiveForm != null)
{
// find field by name
Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField field =
document.InteractiveForm.FindField(fieldFullName);
// if field is found
if (field != null)
{
Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormTextField textField =
field as Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormTextField;
// if field is text field
if (textField != null)
{
// set new value of the field
textField.Value =
new Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormTextFieldStringValue(document, newValue);
return true;
}
}
}
return false;
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5