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

execmenuItem() function not working on initialization of PDF

jayboyle
Registered: Jan 8 2010
Posts: 6

Hi acrobaters, I need help with an issue I am facing. I want the full Comment Toolbar to appear when I open a PDF in the browser with Reader installed.

I have the following code on a button click:

app.execMenuItem('ShowHideToolbarCommenting');

I have Reader Extended the PDF for commenting and it works as expected in Acrobat/Reader and the browser.

Using LC Designer, I move the script to the initialize event and it works only in Acrobat. Using Reader/browser the code does not fire when the PDF is opened.

Looking at the Javascript API guide the execmenuItem() is a privleged function, so I added the following code and saved it out as a .js file to the Reader Javascript folder but it is still not working in Reader/browser.

function enableAnnotateToolbar()
{
app.beginPriv();
app.execMenuItem('ShowHideToolbarCommenting');
app.endPriv();
}
app.trustedFunction(enableAnnotateToolbar);

Can anyone tell me how to get the exexmenuItem() function to fire upon initialization of the PDF in Reader/browser? The behavior is the same in both 8 and 9.

thanks in advance

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
The function enableAnnotateToolbar() can't be executed from within a PDF.
It needs to be placed into a folder level script to work.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jayboyle
Registered: Jan 8 2010
Posts: 6
I have discovered that the execmenuItem() is not supported when using the browser plug in. Even with the function in the folder level script it will not execute. The exexmenuItem() function will work in standalone Reader if you move it to the docReady event but not when opening in the browser.

Even with Comment usage rights added to the PDF; the commenting toolbar button is not visible until you right click the menu bar and enable it.

Which leads me to my next question, does anyone know if there is any documentation\white paper outlining the limitations of using the browser plugin versus standalone Reader; ie other functions that are not supported when using the browser plugin.

thanks,
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

your right, a folder level script will not work in this case.
I read over the fact your using the form in a browser, sorry for that.

So you can only use a button in your form with the script from your function to show/hide the comment toolbar.
Form1.#subform[0].Button1::click - (JavaScript, client)app.execMenuItem("ShowHideToolbarCommenting");

This will work in Acrobat/Reader and also browser, but only manually.
Because the most form events are not supported by the browser plugin you're also not able the fire a script after opening the form that executes the script above.
I was testing a timeout script in the initialize:event which is supported in browsers, but it also only works Acrobat/Reader.
form1::initialize - (JavaScript, client)app.setTimeOut('xfa.form.resolveNode("#subform.Button1").execEvent("click");', 1000);

You can see what events are supported in browsers in the Scripting Basics Manual for LiveCycle Designer.
[url]http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_basics.pdf[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

jayboyle
Registered: Jan 8 2010
Posts: 6
I didn't find this one but you can also enable it through modifying a regkey below and setting to 1.

[HKEY_CURRENT_USER\Software\Adobe\Adobe Acrobat\9.0\Annots\cPrefs]

"bshowAnnotToolsWhenNoCollab"=dword:00000001

If the PDF is Reader Extended then the Commenting Toolbar will be visible when you open in the browser. If at any point you manually close the toolbar, it will not be visible again until you manually enable it again.

HTH