Flatten All Fields in C++

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

Flatten all fields

Flatten all form fields into page content before saving the PDF.

  1. Create Form.
  2. Bind the PDF input with Facade::BindPdf().
  3. Flatten the fields with Form::FlattenAllFields().
  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 FlattenAllFields(String inputFile, String outputFile)
{
    auto form = MakeObject<Form>();
    form->Facade::BindPdf(inputFile);
    form->FlattenAllFields();
    form->Save(outputFile);
}
} // namespace Facades::Examples::PDF_Form