layoutPages property
Function to customize the layout of the pages.
Changes to this function does not take effect until the viewer is re-layout-ed. You can relayout the viewer by calling PdfViewerController.relayout.
The following fragment is an example to layout pages horizontally with margin:
PdfViewerParams(
layoutPages: (pages, params) {
final height = pages.fold(
0.0, (prev, page) => max(prev, page.height)) + params.margin * 2;
final pageLayouts = <Rect>[];
double x = params.margin;
for (final page in pages) {
pageLayouts.add(
Rect.fromLTWH(
x,
(height - page.height) / 2, // center vertically
page.width,
page.height,
),
);
x += page.width + params.margin;
}
return PageLayout(pageLayouts: pageLayouts, documentSize: Size(x, height));
},
),
Implementation
final PdfPageLayoutFunction? layoutPages;