API referenceCore SDK

pdfCreateButton

Create a generic push-button form field.

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

ParameterDescription
IPDFDocument handle.
NameField name — ANSI-only, even for pdfCreateButtonW.
CaptionButton label text.
ParentAccepted but silently droppedAddPushButton has no parenting parameter at all.
PosX, PosY, Width, HeightPlacement box.

Return value. The new button field's handle; 0 if IPDF is invalid.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
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);
Area
Core SDK
Category

Object Creation

Exported names

pdfCreateButtonA pdfCreateButtonW

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.