问题
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