Fill Text Fields in C++

Use Form for this task. The examples below retain the original C++ code and API Reference steps.

Fill text fields

Fill name, address, and email with the sample contact details.

  1. Create Form.
  2. Bind the PDF input with Facade::BindPdf().
  3. Fill the named fields with Form::FillField().
  4. Save the resulting PDF with Form::Save().
#include <Aspose.PDF.Cpp/Facades/Form.h>
#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 FillTextFields(String inputFile, String outputFile)
{
    auto form = MakeObject<Form>();
    form->Facade::BindPdf(inputFile);
    form->FillField(u"name", String(u"John Doe"));
    form->FillField(u"address", String(u"123 Main St, Anytown, USA"));
    form->FillField(u"email", String(u"john.doe@example.com"));
    form->Save(outputFile);
}
} // namespace Facades::Examples::PDF_Form