PdfThumbnail class final

A thumbnail image for a PDF page.

Obtain via PdfDocument.getThumbnail. Pixel data is in BGRA format (4 bytes per pixel, blue first). The source field indicates whether the thumbnail was decoded from an embedded stream or synthesised by rendering the page.

Pixel format

bgra is always a compact BGRA buffer: length == width * height * 4. The bytes are ordered B, G, R, A per pixel, row-major. Row padding from the underlying PDFium bitmap is stripped before delivery.

Embedded vs rendered thumbnails

Embedded thumbnails (PdfThumbnailSource.embedded) are stored directly in the PDF and returned at whatever dimensions the authoring tool chose. Rendered thumbnails (PdfThumbnailSource.rendered) respect maxDimension.

Example — converting a PdfThumbnail to a Flutter dart:ui Image:

final thumb = await doc.getThumbnail(0);
if (thumb != null) {
  final codec = await ui.instantiateImageCodec(
    thumb.bgra,
    targetWidth: thumb.width,
    targetHeight: thumb.height,
  );
  final frame = await codec.getNextFrame();
  final image = frame.image;
}

Constructors

PdfThumbnail({required Uint8List bgra, required int width, required int height, required PdfThumbnailSource source})
Creates an immutable PdfThumbnail.
const

Properties

bgra Uint8List
BGRA pixel bytes. Length is always width * height * 4.
final
hashCode int
The hash code for this object.
no setteroverride
height int
Height of the thumbnail in pixels.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
source PdfThumbnailSource
Whether this thumbnail was decoded from an embedded stream or rendered.
final
width int
Width of the thumbnail in pixels.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override