API referencePDF/A & Conformance

pdfAddValToChoiceField

Append one (export value, display value) option pair to

C
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);
Delphi
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.

ParameterDescription
IPDFDocument handle.
FieldTarget choice field handle.
ExpValueThe export value — ANSI-only in both A and W.
ValueThe display value; Unicode-aware in the W form.
SelectedNon-zero also sets this as the field's current /V.

Return value. True if Field resolves to a known field.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
PDF/A & Conformance
Category

Content Creation

Exported names

pdfAddValToChoiceFieldA pdfAddValToChoiceFieldW

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.