Gamut / Color space problems when using CGContextDrawPDFPage

678 views Asked by At

I'm rendering a PDF file on iPad using core graphics.

The colors however look different to the PDF when opening it using OS X preview or acrobat.

Here is a picture with the left being from Acrobat, the right being in iOS simulator:

enter image description here

Does anyone have an idea what I could be doing wrong? I'm not doing anything fancy with my graphics context, except translation/scaling, clipping and then calling CGContextDrawPDFPage

(So far I have only tried on the iOS simulator. )

2

There are 2 answers

1
Florent On BEST ANSWER

You need to use RGB profile, not CMYK profile.

You can transform your PDF with a Quartz Filter. It will integrate a new color profile in your document, like "Apple RGB".

0
steipete On

This is an old thread, but the problem still persists as of iOS 9.3.2.

Fixing that does not seem to be a priority at Apple. And I can't blame them - they have bigger issues to solve. We reported this bug a few years back and switched to our own rendering engine in the commercial PSPDFKit SDK on both iOS and Android. (Disclaimer: I work there)

The color transform is the only known workaround but requires Adobe Acrobat and manual steps to change. We figured that this is not something that we can burden our customers with so we ultimately replaced Apple's rendering engine - having full control also allowed us to make things both faster and more stable. We have a document that provides some resources on how to get started writing a custom renderer.

Please also report a feedback at https://feedbackassistant.apple.com/ - this is something that eventually should be fixed, and Apple priorities feature requests based on the number of requests. Then again, there are still many open crashers and bugs like missing text that we still have open from the time where we still used CGPDF, so I assume these will have a higher priority.

This support document from Adobe outlines how you can convert the colors: https://helpx.adobe.com/acrobat/using/color-conversion-ink-management-acrobat.html