Extract data from PDF Forms via C++

Extract user data fields from fillable PDF document. Use Aspose.PDF for C++ to modify PDF files programmatically

How to Extract data from PDF Forms using C++ Library

In order to extract data from PDF Forms (Acroforms) in PDF file, we’ll use Aspose.PDF for C++ API which is a feature-rich, powerful and easy to use document manipulation API for cpp platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

How to Extract AcroForm in PDF using C++


You need Aspose.PDF for C++ to try the code in your environment.

  1. Load PDF in an instance of Document class.
  2. Get values from all fields using Document.Form class.
  3. Analyze names and values if needed.
  4. Load PDF in an instance of Document class
  5. Get values from all fields using Document.Form class

Extract data from PDF Forms - C++

This sample code shows how to Extract data from PDF Forms in PDF using C++

    String _dataDir("C:\\Samples\\");
    auto document = MakeObject<Document>(_dataDir + u"GetValuesFromAllFields.pdf");
    for(auto wa : document->get_Form())
    {
        auto formField = System::DynamicCast<Aspose::Pdf::Forms::Field>(wa);

        Console::WriteLine(u"Field Name : {0} ", formField->get_PartialName());
        Console::WriteLine(u"Value : {0} ", formField->get_Value());
    }