VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Tree.InteractiveForms Namespace / PdfDocumentInteractiveForm Class / FindField Method
The fully qualified field name.
Example



In This Topic
    FindField Method
    In This Topic
    Finds a field by specified fully qualified field name.
    Syntax

    Parameters

    fullyQualifiedFieldName
    The fully qualified field name.

    Return Value

    An PdfInteractiveFormField object instance if field is found; otherwise, null.
    Example
    This example shows how find a field with the specified name and change the field value.
    ''' <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;
    }
    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also