Zoom in to specific coordinates in PDFKit using swift

房东的猫 提交于 2020-02-08 02:28:10

问题


I am using pdfkit to open pdf file in my app.

I want to zoom in to specific coordinates.

Let say Following is my pdf page and I want to zoom in to specific coordinates when user will click on pencil button.

After clicking on pencil button it should be look like following image.

I've searched a lot but couldn't find any proper solution for that. I don't want to use third party libraries to do that.


回答1:


I solved this problem by using following code.

let documents = pdfView.document
    if let page = documents?.page(at: 0) {
        pdfView.scaleFactor = pdfView.scaleFactorForSizeToFit * 2
        pdfView.go(to: CGRect(x: 0, y: 0, width: 300, height: 300), on: page)
    }

This is the zoom in code to specific coordinates.

There is one more thing that needs attention. You need to turn off pagination pdfView.usePageViewController(false).



来源:https://stackoverflow.com/questions/60109438/zoom-in-to-specific-coordinates-in-pdfkit-using-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!