1 Reply Latest reply on Oct 6, 2017 3:12 PM by try67

    Rewriting addToolBbutton script to use in Action

    ShirleyP

      I am using Acrobat Pro DC 2015 Classic in a Windows 7 environment. I have made an honest effort to figure out how to do this and referred to the API and several articles, but I guess that am missing too much basic education. My organization uses a script to change redaction overlay scripts for example from "V1" to "V01". I want to be able to run the script from an action instead of from a button. I thought what I needed to do was to replace the "app.addToolButton" to the end with a simple call like RedactionCodeToV01(); but that doesn't seem to work (undefined).I can't figure out how to change the script to run it independent of the button. I've tried to run other options in the console without success (picture "a thousand monkeys typing"). Here is the original javascript function with toolbutton.

       

      function RedactionCodeToV01()

      {

        this.syncAnnotScan();

        var annots = this.getAnnots();

        for each (annot in annots)

        {

        if (annot.type == "Redact")

        {

         if (annot.overlayText == "V1")

         {

      annot.overlayText = "V01";

                }

        }

        }

      }

       

      app.addToolButton({

        cName: "Set any redaction boxes from V1 to new V01 code format",

        cExec: "RedactionCodeToV01()",

        cTooltext: "V1 to V01",

        cEnable: "event.rc = (app.doc != null)"

      });

       

      I would very much appreciate any help or advice. Note that this is not actually my job or training; we just don't have anyone with the necessary expertise.

        • 1. Re: Rewriting addToolBbutton script to use in Action
          try67 MVP & Adobe Community Professional

          If you have the above code installed as a folder-level script, then yes, a simple call to RedactionCodeToV01() from your Action should be enough. And "undefined" does not mean anything went wrong. It simply means the code finished executing without returning any values or throwing any errors, so it's actually a good thing.

          If you use this in an Action, though, make sure you add a command to save the file after calling the script, or the effects of it will be lost.