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

Java script to execute Menu Item

Koen Wyckmans
Registered: Feb 24 2010
Posts: 17
Answered

I'm trying to make a button that executes a menu-item.

More specificly i'm trying to make a button that exports the comments that have been made to a document.

I thought it would work with the following code...

app.execMenuItem("Annots:ExportToGeneralFileMenu")

But it doesn't.

Some help?

try67
Expert
Registered: Oct 30 2008
Posts: 2398
First of all, I think you need to remove the "Annots:" part, but I'm not sure.
Maybe you could be a bit more specific. What exactly happens? Also, which kind of button are you talking about? A form button?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Koen Wyckmans
Registered: Feb 24 2010
Posts: 17
It just doesn't do anything.

I've made a 'regular' button with an action 'Execute Java Script'.

The goal is that the readers can make comments (with the tools in reader), that they can export them and afterwards the comments can be reloaded into the document. But because not all users know of the 'export comments-function', I want to make it easier for them and make a visible button in a sidebar of the document.

Voila...
I hope you understand it.

Koen
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Try it first of all from the Console, to make sure the syntax is correct.

You didn't mention which version of Acrobat/Reader you're using, but if it's version 9 or an updated version 8 you will have security problems since execMenuItem() can only be executed from a safe context, which means you will need to place it in a folder-level script and call it from there.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Koen Wyckmans
Registered: Feb 24 2010
Posts: 17
I use 9.3.1

I already thought that I needed a folder script. But it really has to be a document embedded script otherwise using the button isn't easier than using the menu with a mouse click.

When I'm looking into the console it states that there is a Security issue.

Anyway, except the folder level script, to work around this problem?

Thanks for the help...
try67
Expert
Registered: Oct 30 2008
Posts: 2398
With a folder-level script you will be able to execute the menu item directly from the button, but it will require each user to install the folder-level script on their machine.

Search the forums. This issue have been discussed here several times already.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Koen Wyckmans
Registered: Feb 24 2010
Posts: 17
I'm still finding it strange behaviour... with other menu items it has no problems.

You've been a great help