These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Device Coordinates to Screen Coordinates, Need expert plugin-dev help.

ecoyne
Registered: Jul 1 2010
Posts: 9

I would like to be able to get the global screen coordinates for the current aperture.

The only real screen coordinates I can seem to find in the APIs is to get the Window frame. The problem I have is this includes the scroll-bar, and any shown tool-bars. I could manually compensate for these but the scrollbar-width would be platform specific and the toolbar width's seem like they could fluctuate between Acrobat versions.

This method seems problematic and I was wondering if anyone knew of a clean way to translate device coordinates directly to screen coordinates or a clean way of knowing, in screen coordinates, where the actual aperture view-port is on screen.

ecoyne
Registered: Jul 1 2010
Posts: 9
UPDATE:
I started searching the javascript API and found doc.pageWindowRect which seems exactly what I am looking for.

So further questions would be:
1) is there a Plugin-API equivilent?
2) is there and easy way to call into the Javascript API from the Plugin-API?
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Look at AVPageViewGetAperture in the API reference.

You can execute JS from a plugin using the AFExecuteThisScript method, but only if the user has it enabled. There's a barebones example in the SnippetRunner section of the SDK which opens a dialog and returns the value - getting that to collect any arbitrary chunk of JS is a trivial change in the code.
ecoyne
Registered: Jul 1 2010
Posts: 9
AVPageViewGetAperture will give you what I need but in device coordinates, I need to get them in screen coordinates. I will look at the AFExecuteThisScript, it sounds like what I need for the JavaScript solution thanks.

I also found that AVPageViewAcquireMachinePort() will give me the information from the underlying Windows' window as while it is not mentioned in the API docs it says it in the header file that the machine port it gives you is for just the page-view area of the window and not the whole thing. I am not sure if it is doing the same for mac though.