2

I have an application coded in objective-c that is using CoreGraphics and CGPDFDocument, it's a PDF reader.

With the release of iOS 15 I'm having problems with the rendering of certain pages in certain PDF files. The problem is not present with PDFKit.

I have also downloaded the ZoomingPDFViewer example https://developer.apple.com/library/archive/samplecode/ZoomingPDFViewer/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010281 from the official apple documentation page and I see that the same thing happens.

many image layers are not presents

Yogurt
  • 2,913
  • 2
  • 32
  • 63

1 Answers1

1

Since I have posted a workaround over at the Apple Developer Forums, I wanted to share it here as well. https://developer.apple.com/forums/thread/695439

I can confirm that this problem occurs since iOS 15. As far as I am concerned, I think it is due to a mismapping of the color space, in particular the alpha channel, when rendering the image to the PDF drawing context.

However, I have found a small workaround for the time being. That is setting the bitmap drawing context to non-opaque.

UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);

Regarding the CATiledLayer (used in the ZoomingPDFViewer example), one can simply set the opaque flag to false.

CATiledLayer *tiledLayer = (CATiledLayer *)[self layer];
tiledLayer.opaque = NO;

Of course, it would be ideal if Apple could fix this issue in a future release of iOS. Until then, I hope you find my workaround useful.

richirisu
  • 31
  • 2