Zoom to a specific annotation when the PDF loads
Q: When PDF loads in PSPDFKit, we want to zoom in a particular annotation.
A: You can zoom to an annotation by calling instance.jumpAndZoomToRect()
using the annotation’s bounding box as 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 in the page, with padding around instance.jumpAndZoomToRect(annotation.pageIndex, annotation.boundingBox.grow(padding); }); });
This has been tested with PSPDFKit for Web 2020.1.2.