Core Graphics drawing problems
Has anyone else noticed changes to how annotation drawing callbacks are handled on Mac, in recent versions of Acrobat? We’ve seen our drawing code broken by something in the latest update.
More details:
We have been maintaining our Acrobat plug-in for many years, going back to Acrobat 6, on both Windows and Mac. Part of what we do is custom drawing for annotations from a AVAnnotHandlerDrawExProc callback, using system drawing APIs with a context returned by AVPageViewAcquireDrawContext, either a Windows HDC or a Mac CGContextRef. We draw both to the annotation rectangle, via AVPageViewGetAnnotRect, and to the entire window, adjusted by AVPageViewGetAperture.
On Mac, we have to adjust coordinates for high-resolution Retina displays by the backing scale factor (usually 2), but otherwise, we’ve been able to just take the CGContextRef and draw into it directly, with calls such as CGContextDrawImage and CGContextDrawPDFPage, and things are placed as expected.
At least this is how things worked on Mac until a recent update of Acrobat.
Recently, we’ve gotten reports from users with a latest update of Acrobat DC Pro on Mac that things are being drawn incorrectly. We’ve been able to reproduce the problem as well. It seems that, under certain cases where the page is not completely shown in the window, instead of getting a single call to our AVAnnotHandlerDrawExProc callback, we get multiple calls, with the AVRect set to different subsections of the annotation. Whether we try to draw to that AVRect from the callback, or to the rect returned by AVPageViewGetAnnotRect, we end up drawing to the wrong place, and in multiple places on the window for each callback.
I think what’s happening is that the origin of the CGContextRef is different for each of these subsections we’re getting in these multiple AVAnnotHandlerDrawExProc callbacks. I’ve tried to adjust the coordinate space based on the AVRect passed to the callback, the window aperture, and even the Core Graphics clipping rect, but it seems that we’re missing a key piece of information about how the context has been set up prior to the callback being fired.
Has anyone else experienced this, and have you found a way to work around the changes to the Core Graphics context?
Thanks,
Dan
