Copy link to clipboard
Copied
I'm fooling around with document-level actions and can't seem to get it working. Below is my code:
var didSave = function()
{
console.println("saved!");
};
this.setAction("DidSave", didSave);
This is the error that I get in the console:
TypeError: this.setAction is not a function
47:Folder-Level:App:will_save.js
Using Acrobat X Standard. Any help you can provide is appreciated!
The folder level JavaScript is executed when Acrobat starts, when no documents are open. This is true even if you have double clicked to open a file; Acrobat starts first, then it opens the file. Later it may open more, without Acrobat starting again. Hence in your code "this", whatever it might be, cannot be a document...
Copy link to clipboard
Copied
What context is your code used? Have you confirmed that in this context you can use the "this" object?
Copy link to clipboard
Copied
Thanks for the reply. This code is the sole code that I have and the file resides the the Javascripts folder. The error shows up in the console when I open the document.
Copy link to clipboard
Copied
First open the document then use this.setAction(...);
Copy link to clipboard
Copied
The folder level JavaScript is executed when Acrobat starts, when no documents are open. This is true even if you have double clicked to open a file; Acrobat starts first, then it opens the file. Later it may open more, without Acrobat starting again. Hence in your code "this", whatever it might be, cannot be a document...
Copy link to clipboard
Copied
Ah gotcha. So is there no way to code it so that the above code executes without a user having to interact with a separate button or something? The end goal is: open a document, make a change, hit save, and after hitting save the above code executes.
Copy link to clipboard
Copied
No. You could run an Action on all of your files to embed this code in
them, but you can't do it at the app level for any file that is opened in
it.
On Thu, Sep 21, 2017 at 12:25 AM, four80eastfan <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Ok, so from here, correct (sorry for the idiot questions)?
No way to run an action programmtically, if I'm understanding correctly?
Copy link to clipboard
Copied
When I say "Action" I'm talking about a sort of batch process that you can execute in Acrobat Pro (under Tools - Action Wizard) and run it on multiple files. It has to be triggered manually, though.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now