Skip to main content
four80eastfan
Participating Frequently
September 20, 2017
Answered

set document-level action

  • September 20, 2017
  • 2 replies
  • 893 views

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!

This topic has been closed for replies.
Correct answer Test Screen Name

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...

2 replies

Test Screen NameCorrect answer
Legend
September 20, 2017

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...

four80eastfan
Participating Frequently
September 20, 2017

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.

try67
Community Expert
Community Expert
September 20, 2017

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>

Legend
September 20, 2017

What context is your code used? Have you confirmed that in this context you can use the "this" object?

four80eastfan
Participating Frequently
September 20, 2017

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.

Bernd Alheit
Community Expert
Community Expert
September 20, 2017

First open the document then use this.setAction(...);