Decorate Field in C++

Contents
[ ]

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

Decorate field

Apply a red background, blue text, green border, and centered alignment to First Name.

  1. Configure the field colors and alignment with FormFieldFacade.
  2. Create FormEditor.
  3. Bind the PDF input with Facade::BindPdf().
  4. Set facade through FormEditor using the example values.
  5. Apply the configured appearance with FormEditor::DecorateField().
  6. Save the resulting PDF with SaveableFacade::Save().
#include <Aspose.PDF.Cpp/Color.h>
#include <Aspose.PDF.Cpp/Facades/FormEditor.h>
#include <Aspose.PDF.Cpp/Facades/FormFieldFacade.h>
#include <drawing/color.h>
#include <system/string.h>

namespace Facades::Examples::PDF_FormEditor
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
using DrawingColor = System::Drawing::Color;

void DecorateField(String inputFile, String outputFile)
{
    auto editor = MakeObject<FormEditor>();

    editor->BindPdf(inputFile);
    auto facade = MakeObject<FormFieldFacade>();
    facade->set_BackgroundColor(DrawingColor::get_Red());
    facade->set_TextColor(DrawingColor::get_Blue());
    facade->set_BorderColor(DrawingColor::get_Green());
    facade->set_Alignment(FormFieldFacade::AlignCenter);
    editor->set_Facade(facade);
    editor->DecorateField(u"First Name");
    editor->SaveableFacade::Save(outputFile);
}
} // namespace Facades::Examples::PDF_FormEditor