API referencePDF/A & Conformance

pdfAddButtonImage

Three source variants of the same real feature — give a

C
BOOL32 __stdcall pdfAddButtonImageA(PPDF IPDF, uint32_t BtnHandle, TButtonState State, const char* Caption, const char* ImgFile);
BOOL32 __stdcall pdfAddButtonImageEx(PPDF IPDF, uint32_t BtnHandle, TButtonState State, const char* Caption, void* Handle);
BOOL32 __stdcall pdfAddButtonImageEx2(PPDF IPDF, uint32_t BtnHandle, TButtonState State, const wchar_t* Caption, void* Buffer, uint32_t BufSize);
Delphi
function pdfAddButtonImageA(const IPDF: PPDF; BtnHandle: Cardinal; State: TButtonState; const Caption, ImgFile: PAnsiChar): LongBool; stdcall;
function pdfAddButtonImageEx(const IPDF: PPDF; BtnHandle: Cardinal; State: TButtonState; const Caption: PAnsiChar; Handle: Pointer): LongBool; stdcall;
function pdfAddButtonImageEx2(const IPDF: PPDF; BtnHandle: Cardinal; State: TButtonState; const Caption: PWideChar; const Buffer: Pointer; BufSize: Cardinal): LongBool; stdcall;

Purpose. Three source variants of the same real feature — give a push-button field's given appearance state an image, sourced from a file path, a Windows HBITMAP, or an in-memory encoded image buffer respectively.

Description. All three ultimately call the shared AddButtonImageAssoc(BtnHandle, ImageHandle) after first creating a real image object via a different route: pdfAddButtonImage(A/W) reads a file (CreateImageFromFile); pdfAddButtonImageEx converts a Win32 HBITMAP (Handle) to a 24-bit BMP byte stream (HBitmapToBmpBytes) and feeds it through the normal image path (CreateImageFromBuffer) — genuinely real GDI ingestion, not a stub; pdfAddButtonImageEx2 takes an already-encoded image buffer (JPEG/PNG/ etc. bytes) directly. Caption is accepted by all three but this chapter did not find it consulted anywhere — button captions are set via the separate field-caption APIs (Field Calculation Order, Tooltips, Captions, and Rich Text), not here; the parameter appears vestigial for this specific ABI.

Parameters.

ParameterDescription
IPDFDocument handle.
BtnHandleTarget button/push-button field handle.
StateWhich appearance state (/N//D//R) receives the image.
CaptionAccepted; not observed to be consulted by this specific ABI.
ImgFile*(plain form)* Path to an image file.
Handle*(Ex only)* A Win32 HBITMAP.
Buffer, BufSize*(Ex2 only)* In-memory encoded image bytes.

Return value. True on success; False if the source image couldn't be loaded/decoded or BtnHandle doesn't resolve.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
PDF/A & Conformance
Category

Content Creation

Exported names

pdfAddButtonImage pdfAddButtonImageA pdfAddButtonImageW

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.