我不确定这是不是一个bug,因为iOS上的PDFKit是测试版,但是当我创建一个基于图像数组的图像时(使用PDFPage( PDFDocument:),它会垂直翻转图像。
@IBAction func export(_ sender: Any){
let apdf = PDFDocument()
var i = 0
while i < arrayOfImages.count{
let image = arrayOfImages[i]
let pdfpage = PDFPage(image: image)
apdf.insert(pdfpage!, at: i)
i = i + 1
}
//Code for sharing the PDF Document
let objectsToShare = [apdf.dataRepresentation()]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = view
self.present(activityVC, animated: true, completion: nil)
}输出是这样的:

它应该是这样的:

我100%确定源图像没有翻转,因为它们在应用程序的其他地方使用。您可以设置PDFPage的旋转,但我看不到任何手动翻转它的方法。
发布于 2017-09-14 21:03:50
此错误的一个(坏)解决方案(?)就是提前垂直翻转图像,这样它就可以向后翻转:
let img = arrayOfImages[i]
let image = UIImage(cgImage: img.cgImage!, scale: img.scale, orientation: .downMirrored)
let pdfpage = PDFPage(image: image)https://stackoverflow.com/questions/46219729
复制相似问题