VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    PDF: Get information about fields of PDF interactive form
    In This Topic
    The list of all form fields of PDF interactive form can be obtained using PdfDocumentInteractiveForm.Fields property.


    A form field of PDF interactive form can be found by full field name using PdfDocumentInteractiveForm.FindField method.

    All terminal fields of PDF interactive form can be obtained using PdfDocumentInteractiveForm.GetTerminalFields method. All fields with digital signature can be obtained using PdfDocumentInteractiveForm.GetSignatureFields method.

    Here is C#/VB.NET code that demonstrates how to display information about all fields of PDF interactive form:
    /// <summary>
    /// Prints information about interactive form of PDF document.
    /// </summary>
    /// <param name="pdfFilename">The filename of PDF document.</param>
    public static void PrintInformationAboutPdfInteractiveForm(string pdfFilename)
    {
        // open PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document =
            new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // if PDF document has interactive form
            if (document.InteractiveForm != null)
            {
                // get reference to the interactive form
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm form = document.InteractiveForm;
    
                // get an array that contains all interactive form fields of PDF document
                Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField[] formFields = form.GetTerminalFields();
    
                // print information abount field count
                System.Console.WriteLine("Interactive Form Field Count: {0}", formFields.Length);
    
                // for each interactive field
                foreach (Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField field in formFields)
                {
                    // output information about interactive field
                    System.Console.WriteLine("\tName={0,-18} TypeName={1,-33} TextQuadding={2,-14} IsReadOnly={3,-5}",
                        field.FullyQualifiedName, field.GetType().Name, field.TextQuadding, field.IsReadOnly);
                }
            }
        }
    }
    
    /* This code example produces the following output:
    Interactive Form Field Count: 13
        Name=TextField1         TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=False
        Name=TextField2         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=TextField3         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=TextField4         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=TextField5         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=TextField6         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=NumericField       TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=FileSelect         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
        Name=browseButton       TypeName=PdfInteractiveFormPushButtonField TextQuadding=LeftJustified  IsReadOnly=False
        Name=Calculator.Left    TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=False
        Name=Calculator.Right   TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=False
        Name=Calculator.Result  TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=True
        Name=ResetButton        TypeName=PdfInteractiveFormPushButtonField TextQuadding=LeftJustified  IsReadOnly=False
    */
    
            ''' <summary>
            ''' Prints information about interactive form of PDF document.
            ''' </summary>
            ''' <param name="pdfFilename">The filename of PDF document.</param>
            Public Shared Sub PrintInformationAboutPdfInteractiveForm(pdfFilename As String)
                ' open PDF document
                Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
                    ' if PDF document has interactive form
                    If document.InteractiveForm IsNot Nothing Then
                        ' get reference to the interactive form
                        Dim form As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfDocumentInteractiveForm = document.InteractiveForm
    
                        ' get an array that contains all interactive form fields of PDF document
                        Dim formFields As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField() = form.GetTerminalFields()
    
                        ' print information abount field count
                        System.Console.WriteLine("Interactive Form Field Count: {0}", formFields.Length)
    
                        ' for each interactive field
                        For Each field As Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormField In formFields
                            ' output information about interactive field
                            System.Console.WriteLine(vbTab & "Name={0,-18} TypeName={1,-33} TextQuadding={2,-14} IsReadOnly={3,-5}", field.FullyQualifiedName, field.[GetType]().Name, field.TextQuadding, field.IsReadOnly)
                        Next
                    End If
                End Using
            End Sub
    
            ' This code example produces the following output:
    '        Interactive Form Field Count: 13
    '            Name=TextField1         TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=False
    '            Name=TextField2         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=TextField3         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=TextField4         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=TextField5         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=TextField6         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=NumericField       TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=FileSelect         TypeName=PdfInteractiveFormTextField       TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=browseButton       TypeName=PdfInteractiveFormPushButtonField TextQuadding=LeftJustified  IsReadOnly=False
    '            Name=Calculator.Left    TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=False
    '            Name=Calculator.Right   TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=False
    '            Name=Calculator.Result  TypeName=PdfInteractiveFormTextField       TextQuadding=Centered       IsReadOnly=True
    '            Name=ResetButton        TypeName=PdfInteractiveFormPushButtonField TextQuadding=LeftJustified  IsReadOnly=False
    '