Copy Outer Field in C++

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

Copy outer field

Create a new one-page destination PDF and copy First Name from the source PDF onto it.

  1. Create FormEditor.
  2. Create or open the Document and prepare its pages as shown.
  3. Bind the PDF input with Facade::BindPdf().
  4. Copy the field from the other PDF with FormEditor::CopyOuterField().
  5. Save the resulting PDF with SaveableFacade::Save().
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Facades/FormEditor.h>
#include <Aspose.PDF.Cpp/Page.h>
#include <Aspose.PDF.Cpp/PageCollection.h>
#include <system/string.h>

namespace Facades::Examples::PDF_FormEditor
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;

void CopyOuterField(String inputFile, String outputFile)
{
    auto document = MakeObject<Document>();

    document->get_Pages()->Add();
    document->Save(outputFile);

    auto editor = MakeObject<FormEditor>();

    editor->BindPdf(outputFile);
    editor->CopyOuterField(inputFile, u"First Name", 1, 200, 600);
    editor->SaveableFacade::Save(outputFile);
}
} // namespace Facades::Examples::PDF_FormEditor