render method

Future<PdfPageImage?> render({
  1. required int width,
  2. required int height,
  3. PdfPageFormat format = PdfPageFormat.PNG,
  4. String? backgroundColor,
  5. Rect? cropRect,
})

Render a full image of specified PDF file.

width, height specify resolution to render in pixels. As default PNG uses transparent background. For change it you can set backgroundColor property like a hex string ('#FFFFFF') format - image type, all types can be seen here PdfPageFormat cropRect - render only the necessary part of the image

Implementation

Future<PdfPageImage?> render({
  required int width,
  required int height,
  PdfPageFormat format = PdfPageFormat.PNG,
  String? backgroundColor,
  Rect? cropRect,
}) =>
    _lock.synchronized<PdfPageImage?>(() async {
      if (document.isClosed) {
        throw PdfDocumentAlreadyClosedException();
      } else if (isClosed) {
        throw PdfPageAlreadyClosedException();
      }

      return PdfPageImage._render(
        pageId: id,
        pageNumber: pageNumber,
        width: width,
        height: height,
        format: format,
        backgroundColor: backgroundColor,
        crop: cropRect,
      );
    });