How to Start Convert PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

PDF Form VB.NET Library
How to Read and Extract Field Data in VB.NET


Convenient VB.NET Solution to Read and Extract Field Data from PDF in VB.NET









Look for HTML5 PDF Editor?

EdgePDF: ASP.NET PDF Editor is the best HTML5 PDF Editor and ASP.NET PDF Viewer based on XDoc.PDF, JQuery, HTML5. It supports ASP.NET MVC and WebForms projects.


Overview



Generally, for a full-featured PDF software, it should have functions for processing text, image as well as field. RasterEdge .NET PDF SDK is such one provide various of form field edit functions. This page is mainly designed to tell you how to read or retrieve field data from PDF and how to extract and get field data from PDF in VB.NET project. VB demo codes listed below can help you have a quick evaluation of our PDF SDK.




DLLs: Read and Extract Field Data in VB.NET



In order to run the sample code, the following steps would be necessary.




Demo Code to Retrieve All Form Fields from a PDF File in VB.NET



VB.NET demo code below can help you retrieve PDF file outline.




Dim inputFilePath As String = Program.RootPath + "\\" + "1_AF.pdf"

Dim fields As List(Of BaseFormField) = PDFFormHandler.GetFormFields(inputFilePath)
Console.WriteLine("Number of Fields: " + fields.Count)
If (fields.Count > 0) Then
    For Each field As BaseFormField In fields
        Console.WriteLine("Field")
        Console.WriteLine("  Name:     " + field.Name)
        Console.WriteLine("  Visible:  " + field.IsVisible)
        Console.WriteLine("  Page:     " + field.PageIndex)
        Console.WriteLine("  Position: " + field.Position.ToString())
        Console.WriteLine("  Size:     " + field.Size.ToString())
    Next
End If





VB.NET Demo Code to Get Filled Data in Fields



Please directly copy following VB.NET code sample to your project to get field data from PDF.




Dim inputFilePath As String = Program.RootPath + "\\" + "1_AF_Filled.pdf"

Dim fields As List(Of BaseFormField) = PDFFormHandler.GetFormFields(inputFilePath)
Console.WriteLine("Number of Fields: " + fields.Count)
If fields.Count > 0 Then
    For Each field As BaseFormField In fields
        Console.WriteLine("Field")
        Console.WriteLine("  Name:      " + field.Name)

        If TypeOf field Is AFCheckBox Then
            Console.WriteLine("  Type:      " + "CheckBox")
            Dim obj As AFCheckBox = field
            Console.WriteLine("  IsChecked: " + obj.IsChecked)
        ElseIf TypeOf field Is AFRadioButton Then
            Console.WriteLine("  Type:      " + "RadioButton")
            Dim obj As AFRadioButton = field
            Console.WriteLine("  IsChecked: " + obj.IsChecked)
        ElseIf TypeOf field Is AFTextBox Then
            Console.WriteLine("  Type:      " + "TextBox")
            Dim obj As AFTextBox = field
            Console.WriteLine("  Content:   " + obj.Text)
        ElseIf TypeOf field Is AFListBox Then
            Console.WriteLine("  Type:                " + "ListBox")
            Dim obj As AFListBox = field
            Console.WriteLine("  Selected Item Index: " + obj.SelectedIndexes(0))
        ElseIf TypeOf field Is AFComboBox Then
            Console.WriteLine("  Type:                " + "ComboBox")
            Dim obj As AFComboBox = field
            Console.WriteLine("  Selected Item Index: " + obj.SelectedIndex)
        End If

    Next

End If