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

Looking explanation of execMenuItem

StevenD
Registered: Oct 6 2006
Posts: 368

I'm trying to execute the PDF Optimizer menu item from a tool bar button and am having a hard time following example in the JS reference. Could someone explain the correct syntax of how to get PDF Optimizer to execute?

Here is some code I got from the JS refrence which I modified.

myTrustedMenu = app.trustedFunction( function( name )
{
app.beginPriv();
app.execMenuItem(PDFOptimizer);
app.endPriv();
});

Or can I even get to this in Acrobat 8 with all the stuff locked down because of security reasons?

StevenD

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
What is the error message you are receiving?

Have you created a list of menu items as suggested in the JS Api so you know the cUser name that will be used in JavaScript?

If the parameter in your "app.execMenuItem()" method call is the name of the menu item it has to be a quoted string or you must set the value of the variable PDFOtimizer.

In versilon 5, this menu item has a cUser value of "SpaceReduction".

George Kaiser

jbfreels
Registered: Feb 19 2008
Posts: 63
Works fine for me when I put quotes around "PDFOptimizer".
StevenD
Registered: Oct 6 2006
Posts: 368
app.execMenuItem("PDFOptimizer");

This single line above works fine when run from the JS Console but not from a toolbar button. Not even the script I posted in my original post (including "PDFOPtimizer" in quotes) works except when I select just the above line in the JS Console. Then that part of it works.

Still working with it. Thanks for the help.

StevenD

jbfreels
Registered: Feb 19 2008
Posts: 63
Where are you trying to put this code? I don't think it can exist in a document. You'll have to create a JS file and place it in the javascripts folder under the Acrobat/Reader installation.

Works for me though, with a folder level script.
StevenD
Registered: Oct 6 2006
Posts: 368
I have been trying to put it in a toolbar button so I could activate it without going to the menu. I remembered after I started working on this that there is already a toolbar button built in to Acrobat that will activate the PDF Optimizer so this isn't critical anymore. It just has me stumped that I have made other custom too bar buttons that work but can't get this one to work.

I am using AcroButtons from Windjack Solutions and it has worked very well so far with other buttons. I haven't taken a look yet at the JS file it has made so I'm going to do that and see if I can figure out what is not working or if there is something in it that is holding it back. I will also try moving it to the folder you suggest and see if that makes a difference.

At this point I just want to see if I can crack this.

Thanks for the suggestions.

StevenD

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Are you getting an JavaScript console messages?

Some versions of Acrobat/Reader will require use of the privlage mode.

See [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=13999]addToolButton to execMenuItem not working[/url] for sample code.

George Kaiser

StevenD
Registered: Oct 6 2006
Posts: 368
gkaiseril,

Thanks for the link. I took a quick look at it and will try it out when I get a chance. I will let you know what happens.

StevenD