Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

set document-level action

New Here ,
Sep 20, 2017 Sep 20, 2017

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!

TOPICS
Acrobat SDK and JavaScript
865
Translate
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

correct answers 1 Correct answer

LEGEND , Sep 20, 2017 Sep 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...

Translate
LEGEND ,
Sep 20, 2017 Sep 20, 2017

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

Translate
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
New Here ,
Sep 20, 2017 Sep 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.

Translate
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
Community Expert ,
Sep 20, 2017 Sep 20, 2017

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

Translate
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 ,
Sep 20, 2017 Sep 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...

Translate
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
New Here ,
Sep 20, 2017 Sep 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.

Translate
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
Community Expert ,
Sep 20, 2017 Sep 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>

Translate
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
New Here ,
Sep 20, 2017 Sep 20, 2017

Ok, so from here, correct (sorry for the idiot questions)?

screen.png

No way to run an action programmtically, if I'm understanding correctly?

Translate
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
Community Expert ,
Sep 20, 2017 Sep 20, 2017
LATEST

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.

Translate
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