如何在 iPad 中获取实际的 pdf 页面大小?
如何在 iPad 中获取 PDF 页面的宽度和高度?关于如何找到此信息的任何文件或建议?
How can I get PDF page width and height in iPad? Any document or suggestions on how I can find this information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我一直在使用这里的答案,直到我意识到这一点
在 Apple 的示例 ZoomingPDFViewer 应用程序中使用
I was using the answers here until I realised a one-liner for this
Used in Apple's sample ZoomingPDFViewer app
这是执行此操作的代码;还可以将页面上的点从 PDF 坐标转换为 iOS 坐标。另请参阅使用 Quartz 在 iOS 上获取 PDF 超链接
Here's the code to do it; also to convert a point on the page from PDF coordinates to iOS coordinates. See also Get PDF hyperlinks on iOS with Quartz
以下方法返回根据 Web 视图缩放的第一个 pdf 页面的高度:
它比 Donal O'Danachair 的小很多,并且执行基本相同的操作。您可以轻松地将其调整为您的视图大小,并返回宽度和高度。
The following method returns the height of the first pdf page scaled according to a webview:
It's a lot smaller than Donal O'Danachair's and does basically the same thing. You could easily adapt it to your View size and to return the width along with the height.
Swift 3.x(基于 Ege Akpinar 提供的答案)
更完整的示例展示了如何提取 PDF 文件中页面的尺寸:
Swift 3.x (based on answer provided by Ege Akpinar)
A more full example showing how to extract the dimensions of page in a PDF file:
我采纳了 Donal O'Danachair 的答案并做了一些修改,因此矩形大小也缩放为 pdf 的大小。这段代码实际上是从 pdf 页面获取所有注释,并从 PDF 矩形创建 CGRect。部分代码是 Donal 评论的一个问题的答案。
I took Donal O'Danachair's answer and made a few modifications so the rect size is also scaled to the pdf's size. This code snipped actually gets all the annotations off a pdf page and creates the CGRect from the PDF rect. Part of the code is form the answer to a question Donal commented on his.