// <copyright company="Aspose Pty Ltd">
//   Copyright (C) 2011-2025 GroupDocs. All Rights Reserved.
// </copyright>
namespace GroupDocs.Parser.Examples.CSharp.BasicUsage
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using GroupDocs.Parser.Data;

    /// <summary>
    /// This example shows how to parse a form of the document:
    /// </summary>
    static class ExtractDataFromPdfForms
    {
        public static void Run()
        {
            Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------");
            Console.WriteLine("[Example Basic Usage] # ExtractDataFromPdfForms : This example shows how to parse a form of the document:\n");


            // Create an instance of Parser class
            using (Parser parser = new Parser(Constants.SampleFormsPdf))
            {
                // Extract data from PDF document
                DocumentData data = parser.ParseForm();
                // Check if form extraction is supported
                if (data == null)
                {
                    Console.WriteLine("Form extraction isn't supported.");
                    return;
                }
                // Iterate over extracted data
                for (int i = 0; i < data.Count; i++)
                {
                    Console.Write(data[i].Name + ": ");
                    PageTextArea area = data[i].PageArea as PageTextArea;
                    Console.WriteLine(area == null ? "Not a template field" : area.Text);
                }
            }
        }
    }
}
