Skip to main content
Dan_Korn
Inspiring
December 20, 2023
Question

Core Graphics drawing problems

  • December 20, 2023
  • 1 reply
  • 310 views

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

 

This topic has been closed for replies.

1 reply

ls_rbls
Community Expert
Community Expert
January 16, 2024

Hi @Dan_Korn ,

 

I am not a developer and my knowledge in programming is somewhat limited. But I do have noticed with recent updates that new features are enabled by default.

 

See if the following setting needs to be disabled in Acrobat:

 

  • Preferences => Content Editing => uncheck the box "Enable Auto-adjust layout by default (requires restart)"

 

It would make some sense to me that this setting could be interfering with your plug-in because it automatically locks the form to auto-adjust itself regardless of user interactions. It must be disabled to have the older functionality.

 

PDFs that are produced with InDesing have a similar  document editing feature:

 

  • File => Document Setup => click Adjust Layout