API referenceImages

pdfInsertImageFromBuffer

Same as pdfInsertImage, but decoding from an in-memory

C
int32_t __stdcall pdfInsertImageFromBuffer(PPDF IPDF, double PosX, double PosY, double ScaleWidth, double ScaleHeight, void* Buffer, uint32_t BufSize, uint32_t Index);
Delphi
function pdfInsertImageFromBuffer(const IPDF: PPDF; PosX, PosY, ScaleWidth, ScaleHeight: Double; Buffer: Pointer; BufSize: Cardinal; Index: Cardinal): Integer; stdcall;

Purpose. Same as pdfInsertImage, but decoding from an in-memory buffer instead of a file path.

Description. Format-sniffs the buffer, with two special-cased codec paths ahead of the generic raster decoder: a JPEG2000 codestream is detected (ParseJP2Dims) and embedded directly as /JPXDecode (the PDF viewer decodes it, not this SDK); a JBIG2 generic-region stream is detected (ParseJBIG2Dims) and embedded as /JBIG2Decode, 1-bit DeviceGray. Anything else falls through to the general LoadImageFromBuffer decoder (JPEG/PNG/BMP/TIFF/GIF). Same dropped-parameter defect as pdfInsertImageEx: Index is accepted but never passed to InsertBufferImage, which has no frame-index parameter — multi-frame buffer content always yields the first/only-decoded frame regardless of Index.

Parameters.

ParameterDescription
IPDFDocument handle.
PosX, PosY, ScaleWidth, ScaleHeightPlacement box.
Buffer, BufSizeEncoded image bytes.
IndexAccepted but silently dropped — same limitation as pdfInsertImageEx.

Return value. The new image handle on success; 0 if IPDF is invalid, there is no current page, or the buffer could not be decoded.

See also. pdfInsertImage.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfInsertImageFromBuffer(IntPtr IPDF, double PosX, double PosY, double ScaleWidth, double ScaleHeight, IntPtr Buffer, uint BufSize, uint Index);
Area
Images
Category

Images

Exported names

pdfInsertImageFromBuffer

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.