使用swift放大PDFKit中的特定坐标 [英] Zoom in to specific coordinates in PDFKit using swift
问题描述
我正在使用pdfkit
在我的应用程序中打开pdf文件.
I am using pdfkit
to open pdf file in my app.
我想放大特定的坐标.
I want to zoom in to specific coordinates.
让我们说以下是我的pdf页面,当用户单击铅笔按钮时,我想放大到特定的坐标.
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.
推荐答案
我通过使用以下代码解决了这个问题.
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.
还有另一件事需要注意.您需要关闭 分页
pdfView.usePageViewController(false)
.
There is one more thing that needs attention. You need to turn off pagination
pdfView.usePageViewController(false)
.
这篇关于使用swift放大PDFKit中的特定坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!