ioszoomingpdfkitpdfview

pdfView pinch zooming out


I am trying to move my project that was using a webview to display some pdf to a pdfView to take advantage of the latest PDFKit features.

in the webview when pinching to zoom out the document was always scaling to fill the screen. basically you could not zoom out the page it was bouncing back to fill the screen.

Now with a pdfView, I can zoom out by pinching and it does not look good at all there is no need to have the pdf page to be smaller than the screen...

Is there any way to activate the autoscale once you release your fingers from the screen. I know there is the gesture func but I am not familiar with its use.


Solution

  • Just to confirm that the accepted answer is the correct one, but also to highlight where the code needs to be used (as stated in the comment by answer author). i.e. the code must be used AFTER setting the pdf document:

    pdfView.document = pdfDocument
    pdfView.autoScales = true
    pdfView.maxScaleFactor = 4.0
    pdfView.minScaleFactor = pdfView.scaleFactorForSizeToFit