goToPointInPage method

Future<void> goToPointInPage({
  1. required int pageNumber,
  2. double? padding,
  3. double x = 0.5,
  4. double y = 0.5,
  5. PdfViewerAnchor anchor = PdfViewerAnchor.center,
  6. double? zoomRatio,
  7. Duration duration = const Duration(milliseconds: 500),
})

Go to specific point in page.

x,y should be in 0 1 range and they indicate relative position in the page:

  • 0 for top/left
  • 1 for bottom/right
  • 0.5 for center (the default)

anchor specifies which widget corner, edge, or center the point specified by (x,y) is anchored to.

zoomRatio specifies the zoom ratio. The default is to use the zoom ratio that fit the page into the view. If you want to keep the current zoom ratio, use PdfViewerController.zoomRatio for the value.

If the page does not exist in the layout, it returns null. If the controller is not ready(isReady), the method throws some exception.

Implementation

Future<void> goToPointInPage({
  required int pageNumber,
  double? padding,
  double x = 0.5,
  double y = 0.5,
  PdfViewerAnchor anchor = PdfViewerAnchor.center,
  double? zoomRatio,
  Duration duration = const Duration(milliseconds: 500),
}) =>
    goTo(
      destination: calculatePageMatrix(
        pageNumber: pageNumber,
        padding: padding,
        x: x,
        y: y,
        zoomRatio: zoomRatio,
        anchor: anchor,
      ),
      duration: duration,
    );