XDoc.PDF
Features
Tech Specs
How-to C#
Pricing
How to Start Convert PDF Read PDF Build 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

C# PDF Viewer, Reader Library
How to open, read, view, extract PDF file form field data using c# in winform, asp.net


Help to Read and Extract Field Data from PDF with a Convenient C# Solution in .NET Application










  • A best PDF document SDK library enable users abilities to read and extract PDF form data in Visual C#.NET WinForm and ASP.NET WebForm applications
  • Provide advanced .NET framework components for extracting data from PDF file use Visual Studio .NET-compliant C# language
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • A professional PDF form reader control able to read PDF form field in C#.NET class
  • C# class source codes for collect data from PDF forms in Visual C# .NET program
  • Able to retrieve all form fields from adobe PDF file in C#.NET
  • Support to get form data from specified PDF form position
  • Special customization for export PDF form data to Excel spreadsheet in C#.NET


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 C#.NET project. C# demo codes listed below can help you have a quick evaluation of our PDF SDK.







Read, extract PDF forms data using c#


To get data values from all form fields in a PDF document, you need navigate through all form fields and read, extract data value.



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

List<BaseFormField> fields = PDFFormHandler.GetFormFields(inputFilePath);
Console.WriteLine("Number of Fields: " + fields.Count);
if (fields.Count > 0)
{
    foreach (BaseFormField field in fields)
    {
        Console.WriteLine("Field");
        Console.WriteLine("  Name:      " + field.Name);

        if (field is AFCheckBox)
        {
            Console.WriteLine("  Type:      " + "CheckBox");
            Console.WriteLine("  IsChecked: " + ((AFCheckBox)field).IsChecked);
        }
        else if (field is AFRadioButton)
        {
            Console.WriteLine("  Type:      " + "RadioButton");
            Console.WriteLine("  IsChecked: " + ((AFRadioButton)field).IsChecked);
        }
        else if (field is AFTextBox)
        {
            Console.WriteLine("  Type:      " + "TextBox");
            Console.WriteLine("  Content:   " + ((AFTextBox)field).Text);
        }
        else if (field is AFListBox)
        {
            Console.WriteLine("  Type:                " + "ListBox");
            Console.WriteLine("  Selected Item Index: " + ((AFListBox)field).SelectedIndexes[0]);
        }
        else if (field is AFComboBox)
        {
            Console.WriteLine("  Type:                " + "ComboBox");
            Console.WriteLine("  Selected Item Index: " + ((AFComboBox)field).SelectedIndex);
        }
    }
}




Retrieve all form fields from a PDF file using c#


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

List<BaseFormField> fields = PDFFormHandler.GetFormFields(inputFilePath);
Console.WriteLine("Number of Fields: " + fields.Count);
if (fields.Count > 0)
{
    foreach (BaseFormField field 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());
    }
}




Select a field in a page by position using c#


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

//  select a field at position [110, 310] in page 1 (page index 0)
int pageIndex = 0;
PointF pos = new PointF(110, 310);
//  get the form field object
BaseFormField field = PDFFormHandler.GetFormField(inputFilePath, pageIndex, pos);
if (field != null)
{
    Console.WriteLine("Field " + field.Name + " in page " + field.PageIndex + " at " + field.Position.ToString());
}
else
{
    Console.WriteLine("Field " + field.Name + " does not exist");
}




Select a field in a document by the name using c#


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

//  select a field with name "AF_RadioButton_01"
String fieldName = @"AF_RadioButton_01";
//  get the form field object
BaseFormField field = PDFFormHandler.SelectFormField(inputFilePath, fieldName);
if (field != null)
{
    Console.WriteLine("Field " + field.Name + " in page " + field.PageIndex + " at " + field.Position.ToString());
}
else
{
    Console.WriteLine("Field " + field.Name + " does not exist");
}