Zoom to a Specific Annotation When a PDF Loads

When a PDF loads in PSPDFKit, you can zoom to a specific annotation by calling instance.jumpAndZoomToRect() using the annotation’s bounding box as the target PSPDFKit.Geometry.Rect.

You can also add some padding around the annotation bounding box if needed:

PSPDFKit.load(configuration).then(instance => {
  // Set padding around annotation.
  const padding = 8
  // Get annotations for page 0.
  instance.getAnnotations(0).then(annotations => {
      const annotation = annotations.first();
      // This will target the first annotation found on the page, with padding around.
      instance.jumpAndZoomToRect(annotation.pageIndex, annotation.boundingBox.grow(padding);

This has been tested with PSPDFKit for Web 2020.1.2.