| Category | Form field fonts |
|---|---|
| Exported names | pdfSetFieldFontA, pdfSetFieldFontW |
| Note | Style/Embed/CP accepted but unused (see Remarks) |
Purpose — Set a form field's /DA (Default Appearance) font name and size directly.
Description — Rewrites the field's /DA string as /<Name> <Size> Tf <existing color ops>, preserving whatever color operators were already present. Name is written as a bare resource name reference — it is not validated against the field's /DR (default resources) font dictionary, so if Name doesn't correspond to a real resource entry, rendering falls to viewer-specific substitution.
Declarations
int32_t __stdcall pdfSetFieldFontA(PPDF IPDF, uint32_t Field, const char* Name, int32_t Style, double Size, BOOL32 Embed, TCodepage CP);
int32_t __stdcall pdfSetFieldFontW(PPDF IPDF, uint32_t Field, const wchar_t* Name, int32_t Style, double Size, BOOL32 Embed, TCodepage CP);
function pdfSetFieldFontA(const IPDF: PPDF; Field: Cardinal; const Name: PAnsiChar; Style: Integer; Size: Double; Embed: LongBool; CP: TCodepage): Integer; stdcall; external 'LumasPdf.dll';
function pdfSetFieldFontW(const IPDF: PPDF; Field: Cardinal; const Name: PWideChar; Style: Integer; Size: Double; Embed: LongBool; CP: TCodepage): Integer; stdcall; external 'LumasPdf.dll';
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Field | Cardinal | Target field handle. |
Name | string | Font resource name written verbatim into /DA. Size <= 0 keeps the field's existing /DA size instead of clearing it. |
Style | Integer | Accepted but not read. |
Size | Double | New font size, or <= 0 to keep the existing size. |
Embed | BOOL32 | Accepted but not read — this call never touches font embedding, only the /DA string. |
CP | TCodepage | Accepted but not read. |
Return value — 1 on success; 0 if Field doesn't resolve to a known field.
See also — pdfSetFieldFontSize
C# (P/Invoke)
public static extern int pdfSetFieldFontA(IntPtr IPDF, uint Field, [MarshalAs(UnmanagedType.LPStr)] string Name, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed, TCodepage CP);
public static extern int pdfSetFieldFontW(IntPtr IPDF, uint Field, [MarshalAs(UnmanagedType.LPWStr)] string Name, int Style, double Size, [MarshalAs(UnmanagedType.Bool)] bool Embed, TCodepage CP);
Forms
pdfSetFieldFontA
pdfSetFieldFontW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.