THotPDF.ExtractLoadedImageToStream Method

Writes one loaded image XObject directly to a caller-owned destination without creating a full-size byte array

Declaration

function ExtractLoadedImageToStream(ImageIndex: Integer;
  Destination: TStream; Mode: THPDFLoadedImageStreamMode= lismEncoded): boolean;

Unit

HPDFDoc

Parameters

NamePurpose
ImageIndexZero-based index from GetLoadedImageCount
DestinationCaller-owned stream that receives bytes at its current position
ModelismEncoded copies the native image payload, while lismDecoded executes the generic PDF stream filter chain

Return value

Returns True when the selected image and extraction mode complete successfully

Usage notes

Example

Output := TFileStream.Create('image.bin', fmCreate);
try
  if not PDF.ExtractLoadedImageToStream(0, Output, lismEncoded) then
    raise Exception.Create('Image extraction failed');
finally
  Output.Free;
end;

Related APIs