Customize zoom options in the Flutter PDF viewer
Use the zoom API to control the zoom scale of a PDF page programmatically.
Zoom manually
Get NutrientController from the onControllerReady callback of NutrientDocumentView. Then use zoomToRect(pageIndex, rect) to zoom to an area of a page, and use getZoomScale(pageIndex) to read the current zoom level. Both methods support Android, iOS, and web. Refer to the Nutrient controller(opens in a new tab), zoom to rect(opens in a new tab), and get zoom scale(opens in a new tab) API references for details.
The Rect uses PDF page coordinates. Refer to the coordinate conversion guide for details.
Zoom in to a page area
Use zoomToRect(pageIndex, Rect) to zoom in to a specific Rect on any page. For example, you can zoom to an annotation’s bounding box:
NutrientDocumentView( documentPath: documentPath, onControllerReady: (controller) async { final rect = Rect.fromLTWH(60.0, 700.0, 200.0, 80.0); await controller.zoomToRect(0, rect); },)zoomToRect navigates to the given page if the viewer currently shows another page. You don’t need to switch pages manually.
Use getZoomScale to read the current zoom level of a page:
final scale = await controller.getZoomScale(0);For more information about zooming, open zoom_to_rect_example in the Catalog app.
Disable zooming
To disable zooming, set maximumZoomScale to 1.0 on NutrientViewConfiguration before you create the view. Refer to the Nutrient view configuration(opens in a new tab) API reference for details.
NutrientDocumentView( documentPath: documentPath, configuration: const NutrientViewConfiguration( maximumZoomScale: 1.0, ),)The legacy PdfConfiguration.defaultZoomScale option, which starts a document at a given scale, is part of the deprecated method-channel API and isn’t available on NutrientViewConfiguration.