Get Field Values in C++
Contents
[
Hide
]
Use Form for this task. The examples below retain the original C++ code and API Reference steps.
Inspect form fields
Enumerate field names and print each field’s current value.
- Create Form.
- Bind the PDF input with Facade::BindPdf().
- Read field names through Form.
- Read each field value with Form::GetField().
- Print the results or diagnostic messages shown in the example.
#include <Aspose.PDF.Cpp/Facades/Form.h>
#include <iostream>
#include <system/string.h>
namespace Facades::Examples::PDF_Form
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
using Form = Aspose::Pdf::Facades::Form;
void InspectFormFields(String inputFile)
{
auto form = MakeObject<Form>();
form->Facade::BindPdf(inputFile);
for (auto fieldName : form->get_FieldNames())
{
std::cout << fieldName << " = " << form->GetField(fieldName) << std::endl;
}
}
} // namespace Facades::Examples::PDF_Form