int32_t __stdcall pdfGetXFAFormFieldCount(PPDF IPDF);
const char* __stdcall pdfGetXFAFormFieldNameA(PPDF IPDF, int32_t Index);
const wchar_t* __stdcall pdfGetXFAFormFieldNameW(PPDF IPDF, int32_t Index);
const char* __stdcall pdfGetXFAFormFieldNamesA(PPDF IPDF);
const wchar_t* __stdcall pdfGetXFAFormFieldNamesW(PPDF IPDF);
function pdfGetXFAFormFieldCount(const IPDF: PPDF): Integer; stdcall;
function pdfGetXFAFormFieldNameA(const IPDF: PPDF; Index: Integer): PAnsiChar; stdcall;
function pdfGetXFAFormFieldNameW(const IPDF: PPDF; Index: Integer): PWideChar; stdcall;
function pdfGetXFAFormFieldNamesA(const IPDF: PPDF): PAnsiChar; stdcall;
function pdfGetXFAFormFieldNamesW(const IPDF: PPDF): PWideChar; stdcall;
Purpose. Enumerate the leaf field names present in the XFA datasets packet, by count/index or as one newline-joined list.
Description. All three walk the same XfaFieldList: it locates the packet whose name (after any xdp:...: namespace prefix, matched via Pos(':', nm)) equals datasets (LumasXfaPacketIndex), parses it, descends into its <data> child if present (LumasXfaDataNode), and recursively collects every element that has no element children (LumasXfaCollectLeaves) — i.e. every leaf data value, using each leaf's local (unprefixed) XML tag name as the field name. If there is no datasets packet, or it fails to parse, the count is 0 and the name functions return nil/empty. pdfGetXFAFormFieldNames joins every name with #10 (LF) in enumeration order; there is no delimiter escaping, so a field name that itself contains #10 would corrupt the list (XFA element names cannot contain newlines, so this is not reachable in practice).
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Index | *(Name only)* 0-based position into the leaf list, in document (depth-first) order — not alphabetical, and not stable across edits that add/remove data leaves. |
Return value. pdfGetXFAFormFieldCount: leaf count, 0 if no datasets packet. pdfGetXFAFormFieldName: the leaf's local name, or empty if Index is out of range. pdfGetXFAFormFieldNames: the full #10-joined list.
Remarks. Index here enumerates datasets leaves — a *different* population from the template packet's <field> elements that back pdfGetXFAFormFieldAccess/BorderColor/BorderPresence/BorderWidth below. A name returned here is not guaranteed to also exist as a template field (and vice versa) in a hand-edited or partial XFA document.
C# (P/Invoke)
public static extern int pdfGetXFAFormFieldCount(IntPtr IPDF);
Getters
pdfGetXFAFormFieldCount
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.