Decorate Field in C++
Contents
[
Hide
]
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.
- Configure the field colors and alignment with FormFieldFacade.
- Create FormEditor.
- Bind the PDF input with Facade::BindPdf().
- Set facade through FormEditor using the example values.
- Apply the configured appearance with FormEditor::DecorateField().
- 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