getPageRenderingScale property

PdfViewerGetPageRenderingScale? getPageRenderingScale
final

Function to customize the rendering scale of the page.

In some cases, if maxScale/onePassRenderingScaleThreshold is too large, certain pages may not be rendered correctly due to memory limitation, or anyway they may take too long to render. In such cases, you can use this function to customize the rendering scales for such pages.

The following fragment is an example of rendering pages always on 300 dpi:

PdfViewerParams(
   getPageRenderingScale: (context, page, controller, estimatedScale) {
    return 300 / 72;
  },
),

The following fragment is more realistic example to restrict the rendering resolution to maximum to 6000 pixels:

PdfViewerParams(
   getPageRenderingScale: (context, page, controller, estimatedScale) {
    final width = page.width * estimatedScale;
    final height = page.height * estimatedScale;
    if (width > 6000 || height > 6000) {
      return min(6000 / page.width, 6000 / page.height);
    }
    return estimatedScale;
  },
),

Implementation

final PdfViewerGetPageRenderingScale? getPageRenderingScale;