ByteScout PDF Extractor SDK - C# - Read Values from PDF Form Fields - ByteScout

ByteScout PDF Extractor SDK – C# – Read Values from PDF Form Fields

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Extractor SDK – C# – Read Values from PDF Form Fields

How to read values from PDF form fields in C# and ByteScout PDF Extractor SDK

The tutorial shows how to read values from PDF form fields in C#

Learn how to read values from PDF form fields in C# with this source code sample. What is ByteScout PDF Extractor SDK? It is the SDK is designed to help developers with pdf tables and pdf data extraction from unstructured documents like pdf, tiff, scans, images, scanned and electronic forms. The library is powered by OCR, computer vision and AI to provide unique functionality like table detection, automatic table structure extraction, data restoration, data restructuring and reconstruction. Supports PDF, TIFF, PNG, JPG images as input and can output CSV, XML, JSON formatted data. Includes full set of utilities like pdf splitter, pdf merger, searchable pdf maker and other utilities. It can help you to read values from PDF form fields in your C# application.

C# code samples for C# developers help to speed up coding of your application when using ByteScout PDF Extractor SDK. This C# sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Test C# sample code examples whether they respond your needs and requirements for the project.

Free trial version of ByteScout PDF Extractor SDK is available for download from our website. Get it to try other source code samples for C#.

Try ByteScout PDF Extractor SDK today: Get 60 Day Free Trial or sign up for Web API

Program.cs
      
using System; using System.Xml; using Bytescout.PDFExtractor; namespace ReadValuesFromFormFields { class Program { static void Main(string[] args) { try { // Create XMLExtractor interface using (XMLExtractor extractor = new XMLExtractor("demo", "demo")) { // Load Sample PDF document extractor.LoadDocumentFromFile("filled_form.pdf"); // Get PDF document text as XML string xmlText = extractor.GetXML(); // Load XML XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xmlText); // Select all "control" nodes XmlNodeList formControls = xmlDocument.SelectNodes("//control"); if (formControls != null) { foreach (XmlNode formControl in formControls) { XmlAttribute typeAttribute = formControl.Attributes["type"]; // Get filled textboxes if (typeAttribute.Value == "editbox") { if (!string.IsNullOrEmpty(formControl.InnerText)) { Console.WriteLine("EDITBOX " + formControl.Attributes["id"].Value + ": " + formControl.InnerText); } } // Get checked checkboxes else if (typeAttribute.Value == "checkbox") { if (formControl.Attributes["state"].Value == "1") { Console.WriteLine("CHECKBOX " + formControl.Attributes["id"].Value + ": " + formControl.Attributes["state"].Value); } } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } } }

Try ByteScout PDF Extractor SDK today: 60 Day Free Trial (on-premise version) or sign up for Web API (on demand version)

VIDEO

ON-PREMISE VERSION

Get 60 Day Free Trial or Visit ByteScout PDF Extractor SDK page

Explore ByteScout PDF Extractor SDK documentation

WEB API

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next