PDFKit是垂直翻转PDFPage初始化与图像

问题描述:

不知道这是否是一个错误,因为PDFKit是在iOS上的测试版,但是当我创建基于图像数组的PDFDocument(使用PDFPage(图像:))时,它翻转图像。垂直PDFKit是垂直翻转PDFPage初始化与图像

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

输出是这样的:

enter image description here

当它应该是这样的:enter image description here

我一个m 100%确保源图像不会翻转,因为它们在应用程序中的其他位置使用。您可以设置PDFPage的旋转,但我看不到任何手动将其翻转的方式。

一(坏)解决这个bug是垂直翻转图像提前所以它被弹回来(?):

let img = arrayOfImages[i] 
let image = UIImage(cgImage: img.cgImage!, scale: img.scale, orientation: .downMirrored) 
let pdfpage = PDFPage(image: image) 
+0

事实上,这很奇怪。我希望我们在修正错误后不会陷入困境......但非常感谢解决方法!让我再次去。 – Holtwick