int32_t __stdcall pdfCreateButtonA(PPDF IPDF, const char* Name, const char* Caption, int32_t Parent, double PosX, double PosY, double Width, double Height);
int32_t __stdcall pdfCreateButtonW(PPDF IPDF, const char* Name, const wchar_t* Caption, int32_t Parent, double PosX, double PosY, double Width, double Height);
function pdfCreateButtonA(const IPDF: PPDF; const Name, Caption: PAnsiChar; Parent: Integer; PosX, PosY, Width, Height: Double): Integer; stdcall;
function pdfCreateButtonW(const IPDF: PPDF; const Name: PAnsiChar; const Caption: PWideChar; Parent: Integer; Width, PosY, PosX, Height: Double): Integer; stdcall;
Purpose. Create a generic push-button form field.
Description. **pdfCreateButtonW's Name parameter remains const char* (ANSI) even in the W variant — only Caption is wide; the field's internal /T name is always ANSI-only across both entry points, the same asymmetric-W-variant pattern already confirmed for pdfCreateColItemStringW's Key (Separation Color Spaces, DeviceN Attributes, OCG UI Tree, and PDF Collections). Parent is accepted by the ABI but silently dropped** — confirmed: the underlying AddPushButton implementation has no Parent parameter at all in its signature (only Name, Caption, PosX, PosY, W, H), so there is no hierarchical field-parenting mechanism reachable through this call regardless of what Parent is set to.
Parameters.
| Parameter | Description |
|---|---|
IPDF | Document handle. |
Name | Field name — ANSI-only, even for pdfCreateButtonW. |
Caption | Button label text. |
Parent | Accepted but silently dropped — AddPushButton has no parenting parameter at all. |
PosX, PosY, Width, Height | Placement box. |
Return value. The new button field's handle; 0 if IPDF is invalid.
C# (P/Invoke)
public static extern int pdfCreateButtonA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Name, [MarshalAs(UnmanagedType.LPStr)] string Caption, int Parent, double PosX, double PosY, double Width, double Height);
public static extern int pdfCreateButtonW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Name, [MarshalAs(UnmanagedType.LPWStr)] string Caption, int Parent, double PosX, double PosY, double Width, double Height);
Object Creation
pdfCreateButtonA
pdfCreateButtonW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.