androidzoomingpspdfkit

Android - PSPDFKit is there a way to know the current Zoom on the page?


I am wondering if there is a way to know the zoom in the current document in order to navigate through documents but maintaining the zoom.

thanks,


Solution

  • You can use PSPDFKit#getZoomScale to get zoom scale for current page:

     fragment.getZoomScale(fragment.getPage());
    

    Then, after loading new document, you can set required zoom scale with PSPDFFragment#zoomTo() like this:

     PSPDFDocument document = fragment.getDocument();
     fragment.zoomTo((int) document.getPageSize(pageToDisplay).width / 2,
                     (int) document.getPageSize(pageToDisplay).height / 2,
                     pageToDisplay, zoomScale, animationTime);   
    

    Where animationTime can be 0 to zoom immediately without animating.