Undocumented PDF JavaScript Function

Seems there is at least one undocumented (but live and ready to use) function lurking under PDF JavaScript’s hood, that nobody outside of Adobe knows about. Except, now you are going to know about it, thanks to today’s article! (Didn’t I tell you it would be worth your while to keep tuning in to this page?)

Ready? Here it is. It’s a method that belongs to the App object, called popUpMenu (note the capital letters). The usage is like this:

var fnt = app.popUpMenu('Times-Roman','Helvetica','Courier');
var f = this.getField('MainWindow');
f.textFont = fnt;

What happens is that if you (for example) attach the foregoing 3 lines of JavaScript to a

button’s mouse-up event, you’ll cause a button hit to pop up a menu of typeface choices,

from which the user can choose a new font for the text field named MainWindow.

The popup menu you get when you implement this function does truly ‘pop up’ out of

nowhere, and it functions correctly in that the selection you make takes effect the instant

you let go of the mouse button. So, it’s a wonderful little function (IMHO). Given its

wonderfulness, I asked an Adobe engineer why it wasn’t documented. He as much as said that

Adobe QA (quality assurance) wouldn’t give a ‘pass’ to it for commercial release, because it

‘didn’t behave well enough.’ He wasn’t any more specific than that. I haven’t beat on it

very much, but to me it behaves wonderfully and I intend to use it a lot. The same engineer

that I talked to told me that popUpMenu() will not be deprecated in the future

but in fact will undergo some tweaks in order to make it prime-time ready for Acrobat 5.

So there you go. You now have in your hands an Acrobat 5.0 feature, that no one else

knows about! Use it responsibly.

You May Also Like

About the Author: Kas Thomas

Leave a Reply