【发布时间】:2017-06-07 08:14:47
【问题描述】:
我遇到了错误,但是我尝试在 Swift 中获取 PDF 页面的媒体框。:
if let pdf = CGPDFDocument(pdfURL) {
let numberOfPages = pdf.numberOfPages
for index in 0...numberOfPages {
let pdfPage = pdf.page(at: index)
print(CGPDFPageGetBoxRect(pdfPage!, kCGPDFMediaBox))
}
我也试过了:
print(pdfPage.getBoxRect(kCGPDFMediaBox))
以及使用PDFDisplayBox.mediaBox、mediaBox 以及几乎所有其他变体。它在 python 中运行良好。
我也可以使用PDFPage(而不是CGPDFPage)来获取信息,但我需要使用CGPDFPage 来处理PDFPage 不能做的其他事情。)
第二部分是:据我所知,mediaBox 结果不考虑旋转。所以横向页面可能有一个旋转 90 度的纵向媒体框。有没有简单的方法来获得“实际”显示尺寸,还是我必须自己进行转换?
【问题讨论】: