Skip to content

Render Image

This API allows rendering a specified PDF page as an image. It is useful for generating previews or exporting page content.

The returned data type is Uint8List, which can be used directly for display or saving as an image file.

Method Declaration

dart
Future<Uint8List> renderPage({
  required int pageIndex,
  required int width,
  required int height,
  Color backgroundColor = Colors.white,
  bool drawAnnot = true,
  bool drawForm = true
})

Parameters

ParameterTypeRequiredDescription
pageIndexintYesThe index of the page to render, starting from 0
widthintYesWidth of the rendered image in pixels
heightintYesHeight of the rendered image in pixels
backgroundColorColorNoPage background color, default is white, Android only
drawAnnotboolNoWhether to render annotations, default true, Android only
drawFormboolNoWhether to render form fields, default true, Android only

Example Usage

dart
final pageImage = await controller.renderPage(
  pageIndex: 0,
  width: 1080,
  height: 1920,
  backgroundColor: Colors.white,
  drawAnnot: true,
  drawForm: true,
);

// Display the image
Image.memory(pageImage);