ios - 使用 swift 放大到 PDFKit 中的特定坐标

标签 ios swift pdf zooming pdfkit

我正在使用 pdfkit 在我的应用程序中打开 pdf 文件。

I want to zoom in to specific coordinates.

假设以下是我的 pdf 页面,当用户单击铅笔按钮时,我想放大到特定坐标。

enter image description here

单击铅笔按钮后,它应该如下图所示。

enter image description here

我进行了很多搜索,但找不到任何合适的解决方案。我不想使用第三方库来做到这一点。

最佳答案

我使用以下代码解决了这个问题。

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)
    }

这是放大到特定坐标的代码。

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

关于ios - 使用 swift 放大到 PDFKit 中的特定坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60109438/

相关文章:

ios - 右约束警告

swift - UITableViewCell 中 UIImage 的 UITest 查询

ios - 试图使 UIImageView 成为一个圆圈,它出现两次

pdf - 我应该在我的站点地图文件中列出 PDF 吗?

excel - 如何将 .XLS 和 .XLSX 文件转换为 .PDF 格式并将它们返回到 Powershell 中的每个原始子文件夹?

javascript - python - 在网络服务中以字节形式发送 pdf

ios - 呈现的模态视图 Controller 未像表单一样显示

ios - iOS应用双向数据交换

swift - 加载到 View 后的 CollectonView "readjusts"原点

ios - 以编程方式锁定 iPhone (>iOS7)