renderPageToBytes method

Future<({int pixelHeight, int pixelWidth, Uint8List pixels})> renderPageToBytes(
  1. int pageIndex,
  2. int pixelWidth,
  3. int pixelHeight, {
  4. bool renderAnnotations = true,
  5. bool lcdText = false,
  6. int backgroundColor = 0xFFFFFFFF,
})

Renders a page to a raw BGRA pixel buffer.

The page at pageIndex is rendered at pixelWidth × pixelHeight pixels. The returned record exposes pixels (BGRA bytes), pixelWidth, and pixelHeight.

For Flutter apps, decode the returned BGRA bytes into a dart:ui Image via decodeImageFromPixels.

renderAnnotations maps to the PDFium FPDF_ANNOT flag (default true). lcdText maps to FPDF_LCD_TEXT (default false). backgroundColor is an ARGB packed integer; default 0xFFFFFFFF (opaque white).

Throws RangeError if pageIndex is out of range. Throws StateError if close has been called before or during render. Throws PdfiumException if a PDFium native call fails.

Implementation

Future<({Uint8List pixels, int pixelWidth, int pixelHeight})>
renderPageToBytes(
  int pageIndex,
  int pixelWidth,
  int pixelHeight, {
  bool renderAnnotations = true,
  bool lcdText = false,
  int backgroundColor = 0xFFFFFFFF,
}) => _impl.renderPageToBytes(
  pageIndex,
  pixelWidth,
  pixelHeight,
  renderAnnotations: renderAnnotations,
  lcdText: lcdText,
  backgroundColor: backgroundColor,
);