API referenceImages

pdfGetImageObjEx

Read an image's full metadata and pixel/compressed byte

C
BOOL32 __stdcall pdfGetImageObj(PPDF IPDF, uint32_t Handle, TParseFlags Flags, TPDFImage* Image);
BOOL32 __stdcall pdfGetImageObjEx(PPDF IPDF, PIMG ImagePtr, int32_t Flags, TPDFImage* Image);
Delphi
function pdfGetImageObj(const IPDF: PPDF; Handle: Cardinal; Flags: TParseFlags; var Image: TPDFImage): LongBool; stdcall;
function pdfGetImageObjEx(const IPDF: PPDF; ImagePtr: PIMG; Flags: Integer; var Image: TPDFImage): LongBool; stdcall;

Purpose. Read an image's full metadata and pixel/compressed byte buffer, either directly by the document's own image handle (pdfGetImageObj) or through a standalone PIMG object minted earlier by pdfCreateImageObj (pdfGetImageObjEx).

Description. pdfGetImageObj fills Image from the live FImages entry — its returned Image.Buffer points into a transient, shared read-back buffer that is only valid until the next call that reuses it (freed/invalidated by pdfFreeImageObj(IPDF, 0), below). pdfGetImageObjEx instead reads from a TLumasImageObj's own private, independently-owned byte copy (O.OwnBuf, populated once at pdfCreateImageObj time) — its Image.Buffer stays valid for the PIMG object's entire lifetime, not just until the next call, making it the safer choice when the caller needs to hold onto the buffer across other API calls. Both honor a pfImageInfoOnly flag bit ($80): when set, every metadata field is still filled but Image.Buffer/Image.BufSize are forced to nil/0, letting a caller query dimensions/format cheaply without paying for the byte copy.

Parameters.

ParameterDescription
IPDFDocument handle.
Handle*(plain)* An existing document image handle.
ImagePtr*(Ex)* A PIMG minted by pdfCreateImageObj.
FlagsParse/query flags; bit $80 (pfImageInfoOnly) suppresses the byte-buffer copy.
ImageOutput: full TPDFImage metadata + (unless info-only) pixel/compressed bytes.

Return value. True if the handle/pointer resolved; False otherwise.

See also. pdfCreateImageObj, pdfFreeImageObj (buffer lifetime for the plain form).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Images
Category

Getters

Exported names

pdfGetImageObjEx

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.