VB.NET PDF: How to HTML5 PDF Viewer PDF Create PDF Export File & Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF PDF Viewer Work with Other SDKs Barcode Read Barcode Create OCR Twain
Data: Read, Extract Field Data
  |  
Home ›› XDoc.PDF ›› VB.NET PDF: Read, Extract Field Data

VB.NET PDF - Read and Extract Field Data in VB.NET


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




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.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Raster.dll


  RasterEdge.XDoc.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;




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