Skip to main content
Participant
August 16, 2019
Question

Can't get a simple "app.execMenuItem("Save")" to function!

  • August 16, 2019
  • 2 replies
  • 421 views

Hi all,

I have a simple script that flattens a page. It works well. I just want to add a command so that the document saves once the page has been flatten:

function Flatten(boolCurrentPageOnly) // Takes a boolean argument

{
if (boolCurrentPageOnly)                          // Flatten either this page...
   {
   this.flattenPages(this.pageNum);
    app.execMenuItem("Save")                    //That's where I inserted  the new command. All works fine otherwise. Except that it doesn't save  the doc.
   }
else

   {

   this.flattenPages();                                 // ...or all pages

   app.execMenuItem("Save")                    //That's where I inserted  the new command. All works fine otherwise. Except that it doesn't save  the doc.

   }

}


//Installs the menu


app.addMenuItem({
   cName: "Flatten current page",
   cParent: "Document",
   cExec: "Flatten(true)"});

app.addMenuItem({
  cName: "Flatten all pages",
  cParent: "Document",
  cExec: "Flatten(false)"});

Anything I am doing wrong?

I am on Acrobat 9.

Thanks!

app.execMenuItem("Save")

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
August 16, 2019

You can't do that, unless you edit the registry to white-list "Save".

You can use the saveAs method, though, from a privileged context, to achieve it.

Legend
August 16, 2019

Is "Save" one of the safe menu items? I doubt it, but you can use the method described in the documentation to find out.