while we make a pdf using an image file at that we add an image into PDFPage. at that time PDFDocument did not show the original image content in PDFView in iOS 16. I checked the same code which worked properly in iOS 15. For both test cases, I used New Xcode 14, and as well as previously uploaded TestFlight build also worked properly with iOS 15 or below but did not work with iOS 16. So I request to the apple developer who worked on PDFkit please check this case. I may be sure that there is an issue with iOS 16 and I hope apple provides a new iOS 16 sub-version release as soon as possible with includes this bug fix. here is the sample code that I used:-
let images = [UIImage]()
let pdfDocument = PDFDocument()
for (index,image) in images.enumerated(){
// Create a PDF page instance from your image
let pdfPage = PDFPage(image: image)
// Insert the PDF page into your document
pdfDocument.insert(pdfPage!, at: index)
}
Original Image:
PDF preview in PDFView:
2
Answers
My guess is there’s an issue with the default color space in PDFKit: RGB vs CMYK
Here’s a workaround:
You’ll have to alter it for multiple pages in your instance
Try to remove alpha channel from the image before inserting it into PDFPage. Below is an example how to remove alpha channel from UIImage. Tested with iOS 16.1.