Create ComboBox Field in C++
Contents
[
Hide
]
Use FormEditor for this task. The examples below retain the original C++ code and API Reference steps.
Create combo box field
Create combobox1 on page 1 and add Australia and New Zealand choices.
- Create FormEditor.
- Bind the PDF input with Facade::BindPdf().
- Create the fields with FormEditor::AddField().
- Add choice items with FormEditor::AddListItem().
- Save the resulting PDF with SaveableFacade::Save().
#include <Aspose.PDF.Cpp/Facades/FieldType.h>
#include <Aspose.PDF.Cpp/Facades/FormEditor.h>
#include <system/array.h>
#include <system/string.h>
namespace Facades::Examples::PDF_FormEditor
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
void CreateComboBoxField(String inputFile, String outputFile)
{
auto editor = MakeObject<FormEditor>();
editor->BindPdf(inputFile);
editor->AddField(FieldType::ComboBox, u"combobox1", u"Australia", 1, 230, 498, 350, 514);
editor->AddListItem(u"combobox1", MakeArray<String>({u"Australia", u"Australia"}));
editor->AddListItem(u"combobox1", MakeArray<String>({u"New Zealand", u"New Zealand"}));
editor->SaveableFacade::Save(outputFile);
}
} // namespace Facades::Examples::PDF_FormEditor