我遇到了错误,但是我尝试在 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))
以及 using PDFDisplayBox.mediaBox
,mediaBox
以及几乎所有其他变体。它在 python 中运行良好。我也可以使用PDFPage
(而不是CGPDFPage
)获得信息,但我需要CGPDFPage
用于其他PDFPage
不能做的事情。)
第二部分是:据我所知, mediaBox 结果不考虑旋转。所以横向页面可能有一个旋转 90 度的纵向媒体框。有没有简单的方法来获得“实际”显示尺寸,或者我必须自己进行转换?