API referenceForms

pdfFindField

Look up a field's document-wide handle by its fully-

C
int32_t __stdcall pdfFindFieldA(PPDF IPDF, const char* Name);
int32_t __stdcall pdfFindFieldW(PPDF IPDF, const wchar_t* Name);
Delphi
function pdfFindFieldA(const IPDF: PPDF; const Name: PAnsiChar): Integer; stdcall;
function pdfFindFieldW(const IPDF: PPDF; const Name: PWideChar): Integer; stdcall;

Purpose. Look up a field's document-wide handle by its fully- qualified name.

Description. pdfFindFieldW's wide-to-narrow conversion is a raw per-character truncation (AnsiChar(Ord(Name[I-1]) and $FF) — masking each UTF-16 code unit to its low byte) rather than a real codepage-aware narrowing — the same class of lossy manual-conversion issue already documented for pdfFindBookmarkA's ANSI-to-Wide direction (Named Destinations, Page Labels, Geospatial Measure, and Viewports), here running the opposite direction (Wide-to-ANSI). Non-Latin1 field names passed to pdfFindFieldW will not reliably match the stored (narrowed) field name.

Parameters.

ParameterDescription
IPDFDocument handle.
NameThe fully-qualified field name to search for.

Return value. The matching field's handle; 0 if not found.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfFindFieldA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Name);
public static extern int pdfFindFieldW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPWStr)] string Name);
Area
Forms
Category

Core

Exported names

pdfFindFieldA pdfFindFieldW

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.