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

New Here ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

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")

TOPICS
Acrobat SDK and JavaScript, Windows

Views

96

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 15, 2019 Aug 15, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines