ByteScout PDF Extractor SDK - C# - Extract Filled Form Data - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF Extractor SDK – C# – Extract Filled Form Data

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Extractor SDK – C# – Extract Filled Form Data

ByteScout PDF Extractor SDK – C# – Extract Filled Form Data

Program.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Diagnostics;
using System.Xml;
using Bytescout.PDFExtractor;
 
namespace ExtractFilledFormData
{
    static class Program
    {
        static void Main()
        {
            // Create XMLExtractor instance
            XMLExtractor extractor = new XMLExtractor();
            extractor.RegistrationName = "demo";
            extractor.RegistrationKey = "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"];
 
                    // Show filled textboxes
                    if (typeAttribute.Value == "editbox")
                    {
                        if (!String.IsNullOrEmpty(formControl.InnerText))
                            Console.WriteLine("EDITBOX " + formControl.Attributes["id"].Value + ": " + formControl.InnerText);
                    }
                    // Show checked checkboxes
                    else if (typeAttribute.Value == "checkbox")
                    {
                        if (formControl.Attributes["state"].Value == "1")
                            Console.WriteLine("CHECKBOX " + formControl.Attributes["id"].Value + ": " + formControl.Attributes["state"].Value);
                    }
                }
            }
 
            // Cleanup
            extractor.Dispose();
 
            Console.WriteLine();
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
    }
}

  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next