Skip to main content
Participant
September 29, 2020
Question

doc.pageWindowRect and doc.media are undefined in Acrobat Javascript

  • September 29, 2020
  • 2 replies
  • 1541 views

I am trying to use the doc.pageWindowRect information as part of some code I am writing using the Adobe Acrobat Javascript API.

 

I originally found that doc.pageWindowRect was undefined, and through various posts on this forum, found that I needed to activate the media extension first, by running something like

console.println(this.media);

 Normally this prints something like:

[object DocMedia]

but on some computers used by our client, this just prints 'undefined' instead. It seems that having this.media undefined means that doc.pageWindowRect will stay undefined too.

 

Does anyone know how to make sure this.media is defined, and thus enable doc.pageWindowRect? Or any other way of getting hold of the doc.pageWindowRect information?

 

I wondered if there might be a delay in activating the media extension, and have tried repeatedly running code to display this.media and doc.pageWindowRect using app.setInterval, but even after waiting for a couple of minutes, they are still not defined.

 

Could this be related to the configuration of our client's Acrobat install? It seems to work fine on most other machines that we've tested it on, but there is definitely some sort of problem here.

 

Any help would be much appreciated.

 

Thanks,

 

Robin

This topic has been closed for replies.

2 replies

Legend
September 30, 2020

A weird thought: does this happen if you have already opened the Acrobat Reader app? I'm wondering about slow startup of these components. Also: check the list of installed plug-ins in the Help menu.

Robin5E47Author
Participant
September 30, 2020

Sometimes it seems like opening the app first helps - but I'd have thought that the investigation I've done using a timer to print out the values of this.media and this.pageWindowRect would show up any delay in loading the components. The timer runs for over 1.5 minutes, and at the end of that time the values are still showing up as undefined.

 

I'll ask our clients to check their installed plugins list.

 

Thanks.

try67
Community Expert
Community Expert
September 30, 2020

I'm getting strange results with this object, too. Sometimes it works, other times it doesn't. And when it fails, it seems to also affect other files that otherwise would have worked... Seems not to be too stable.

try67
Community Expert
Community Expert
September 29, 2020

Does this happen with a specific version of Acrobat? Or maybe on a specific OS version?

Robin5E47Author
Participant
September 29, 2020

Thanks for the response.

 

They're using an older version of Adobe Reader to view the document (due to security requirements) - their app.viewerVersion is 17.01130171, and they're using Windows 7.

 

However, we've installed that version on a Windows machine and can't reproduce the error - it works fine for us.

 

Do you know if there are any preferences settings that could affect whether this.media or doc.pageWindowRect are available? Or any other 'best guess' ideas as to why these might be undefined?

 

 

try67
Community Expert
Community Expert
September 29, 2020

How are you running this code, exactly? In what context?