CGContextDrawPDFPage() shows incorrect CMYK colors on El Capitan

Originator:greg
Number:rdar://22904428 Date Originated:2015-09-29
Status:Open Resolved:
Product:OS X Product Version:15B42
Classification:Serious Bug Reproducible:Always
 
Summary:
I have a PDF which uses CMYK color and OPM (overprint mode). When this PDF is drawn using CGContextDrawPDFPage(), the text content appears, incorrectly, in blue. When this PDF is drawn into a PDFView using PDFKit, the text content appears in black, as it should. Opening the same PDF in Preview shows black text, as does opening it in Adobe Reader.

Steps to Reproduce:
1. Double-click to uncompress CGCMYKBug.zip <https://smilesoftware.com/downloads/CGCMYKBug.zip>
2. Double-click top open the CGCMYKBug folder
3. Open the TestCG.xcodeproj, using Xcode 7 on OS X 10.11.1 (15B42)
4. Run the TestGC target

Doing that will open two windows -- one titled "CoreGraphics" and the other titled "PDFKit".

5. Choose "PDFKit" from the Window menu

Note that the text appears in black and dark gray.

6. Choose "CoreGraphics" from the Window menu

Note that the text appears in blue and light blue.


Expected Results:
I expected the text to appear in black and dark gray in both windows.


Actual Results:
When drawn using CGContextDrawPDFPage(), the text color is not correct.


Version:
OS X 10.11.1 (15B42)


Configuration:
15-inch, Late 2013 Retina MacBook Pro
16GB RAM
OS X 10.11.1 (15B42)

Comments

Turns out, the bug is limited to PDFs with transparency layers.

The workaround is to wrap the drawing in begin / end transparency layer calls:

CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextBeginTransparencyLayer(context, NULL);
CGContextDrawPDFPage(context, page);
CGContextEndTransparencyLayer(context);

The bug remains on macOS Sierra.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!