renderImage method
Fetches the rendered BGRA bitmap for a single image object on a page.
pageIndex is the zero-based page index. objectIndex is the position
of the image object in the page's object list, as reported by
PdfImage.objectIndex from extractImages.
Returns a PdfImageBitmap containing the composited BGRA pixel data,
or null when the object has no renderable bitmap (e.g. a mask-only
image where FPDFImageObj_GetRenderedBitmap returns null).
Each call is one isolate round-trip. For bulk extraction of many images
from the same page, prefer calling extractImages with
includeBitmap: true instead.
Throws RangeError if pageIndex is out of range for the document.
Throws RangeError if objectIndex is negative, or if objectIndex
is out of range for the page (the object does not exist).
Throws StateError if the document has been closed.
Platform support: Native (dart:ffi) only. Stubs on unsupported platforms throw UnsupportedError.
Example — render only large images:
await for (final page in doc.extractImages()) {
for (final img in page.images) {
if (img.metadata.width > 500 && img.metadata.height > 500) {
final bitmap = await doc.renderImage(img.pageIndex, img.objectIndex);
if (bitmap != null) {
// process bitmap.bgra…
}
}
}
}
Implementation
Future<PdfImageBitmap?> renderImage(int pageIndex, int objectIndex) =>
_impl.renderImage(pageIndex, objectIndex);