API reference › PDF/A & Conformance
pdfAddValToChoiceField
Append one (export value, display value) option pair to
BOOL32 __stdcall pdfAddValToChoiceFieldA(PPDF IPDF, uint32_t Field, const char* ExpValue, const char* Value, int32_t Selected);
BOOL32 __stdcall pdfAddValToChoiceFieldW(PPDF IPDF, uint32_t Field, const char* ExpValue, const wchar_t* Value, int32_t Selected);
function pdfAddValToChoiceFieldA(const IPDF: PPDF; Field: Cardinal; const ExpValue, Value: PAnsiChar; Selected: Integer): LongBool; stdcall;
function pdfAddValToChoiceFieldW(const IPDF: PPDF; Field: Cardinal; const ExpValue: PAnsiChar; const Value: PWideChar; Selected: Integer): LongBool; stdcall;
Purpose. Append one (export value, display value) option pair to a choice field's /Opt array — the real ABI entry point behind this volume's grab-bag inclusion, and the same AddValToChoiceField method already documented as the backing for pdfSetFieldExpValue (Field Values).
Description. Per the Field Values finding, this always appends unconditionally (Opt.Add(Pair)) — there is no insert-at-index or replace behavior despite pdfSetFieldExpValue's sibling ValIndex parameter implying positional control elsewhere in this same underlying method's other callers. Selected <> 0 additionally sets the field's current value (/V) to Value. ExpValue stays ANSI in both A and W variants — only Value (the display string) gets the Unicode-aware PWideToPdfText treatment in the W form, the same asymmetric-Unicode-parameter pattern documented for several other W-suffixed functions in this manual.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Field | Target choice field handle. |
ExpValue | The export value — ANSI-only in both A and W. |
Value | The display value; Unicode-aware in the W form. |
Selected | Non-zero also sets this as the field's current /V. |
Return value. True if Field resolves to a known field.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Content Creation
pdfAddValToChoiceFieldA
pdfAddValToChoiceFieldW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.