THPDFPage.AddComboBox

THPDFPage

 

Methods  AcroForm Support

Adds an AcroForm combo box choice field to the current page

 

Delphi syntax:

procedure AddComboBox(const FieldName, InitialValue: AnsiString; const Options: array of AnsiString; Rectangle: TRect; Flags: THPDFFormFieldFlags = []);

 

Description

The method creates a /Ch field with the Combo flag. Options supplies the visible choices and InitialValue selects the initial value when it matches one of those choices

With ffSort, the writer sorts the stored option strings using Windows invariant CompareStringW with NORM_IGNORECASE and SORT_STRINGSORT; linguistic ties retain caller order, and clearing the flag preserves the original order

This comparison uses Windows NLS weights rather than a universal alphabet: case-related and other tertiary distinctions can compare equal, secondary weights remain active, and canonical or ignorable sequences may tie; the invariant locale avoids user-locale dependence, whilst weights can vary across Windows versions

Sorting retains the original option text and InitialValue; exact Unicode equality still identifies the selected spelling, so linguistic ties neither merge options nor select a different value

Option strings and InitialValue preserve UTF-8 text and ASCII control scalars, including embedded NUL, through UTF-16 text-string storage when PDFDocEncoding cannot represent them faithfully; the existing selected-caption appearance behaviour is retained

For generated listbox option rows and the standard-font rendering boundary, see AddListBox

 

THPDFPage.AddComboBoxWithLabels

Creates a single-choice combo box whose stored export values are separate from the labels shown to the user

Windows component signature

procedure AddComboBoxWithLabels(const FieldName: AnsiString;
          const ExportValues, DisplayLabels: array of AnsiString;
          SelectedIndex: Integer; Rectangle: TRect;
          Flags: THPDFFormFieldFlags = []);

This signature belongs to HPDFDoc.THPDFPage and accepts the same field-flag type as the component's existing AddComboBox method

Native UNIX canvas signature

procedure AddComboBoxWithLabels(const Name: AnsiString;
          const ExportValues, DisplayLabels: array of AnsiString;
          SelectedIndex: Integer; const Bounds: TRect);

This signature belongs to HPDFHeadlessCanvas.THPDFPage, has no Flags parameter and preserves caller option order; the two units' page classes are separate APIs

Values, labels and selection

The arrays must have equal lengths, and each matching pair becomes a two-string /Opt entry containing its export value followed by its display label. Strings retain the existing backend's UTF-8 field-storage contract and appearance-font limits

For non-empty arrays, SelectedIndex is a zero-based index in the caller's arrays and must be in range. The chosen export is written as /V, including an explicitly empty string, whilst the generated caption uses its paired label

The single entry in /I identifies the selected stored option even when different labels have equal export strings; selection is not inferred by searching for a matching export or label

With component ffSort, the existing invariant comparison orders display labels whilst retaining the original order of ties, moving each export-label pair together and remapping /I to the selected pair's stored position. The comparison rules and Windows NLS boundary described above for AddComboBox also apply here

Empty arrays create /Opt [] and /I [] with no selected option; SelectedIndex is ignored in that case, and the stored empty-value representation follows the backend's existing empty-field convention

The component honours the document's existing appearance-generation policy; the native canvas uses its existing supplied-font appearance path. Separating labels from exports does not add a new font fallback or shaping provider

See also: AcroForm Support, LastAnnotation