Mac: Can you script toggling between the Acrobat JavaScript Editor and an external editor?

Explorer ,
Nov 18, 2017

Copy link to clipboard

Copied

Does a script exist or can it be created for the Mac environment to toggle between the internal and an external JS editor, and perhaps place it in a button? It would be nice to shorten up the process of opening & closing Preferences to switch back and forth.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

181

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

Mac: Can you script toggling between the Acrobat JavaScript Editor and an external editor?

Explorer ,
Nov 18, 2017

Copy link to clipboard

Copied

Does a script exist or can it be created for the Mac environment to toggle between the internal and an external JS editor, and perhaps place it in a button? It would be nice to shorten up the process of opening & closing Preferences to switch back and forth.

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

182

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
Nov 18, 2017 0
Adobe Community Professional ,
Nov 18, 2017

Copy link to clipboard

Copied

There isn't. But even if there were, you'l shortly find that you don't want it.

The Acrobat JavaScript editor is... [pause, deep breath]... limited. You don't get any syntax highlighting, it has a tendency to crash, and only stores your JavaScript in the PDF file so version control can be problematic. The connection to the external editor is problematic as well. Some editors don't release the file when you just close it, you need to shut down the application as well so I don't set up an external editor either.

Edit your scripts outside of Acrobat using the editor of your choice and then just copy/paste them into the places you want them. As much as possible, create functions that go into one or more document level scripts and only put calls to those functions in the fields themselves.

There are some clever things you can do with Actions to streamline the process of getting the JS file into the document automatically. 

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
Reply
Loading...
Nov 18, 2017 1
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

Has anyone ever managed to use an external editor on MacOS?

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
Reply
Loading...
Nov 19, 2017 0
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

Yes. I use TextMate. The only problem is that you have to shut down the editor to get back to Acrobat, just closing the document is not sufficient.

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
Reply
Loading...
Nov 19, 2017 2
Most Valuable Participant ,
Nov 19, 2017

Copy link to clipboard

Copied

The same thing hapoens with many Windows editors, too, which is why I never

use them unless I have to.

On Nov 19, 2017 2:28 PM, "Karl Heinz Kremer" <forums_noreply@adobe.com>

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
Reply
Loading...
Nov 19, 2017 1
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

I use Notepad++ with Windows. Starts up fast, so it's not a problem.  It also keeps all the previously open files open, so you never loose edits. Much, much better than using the Acrobat JS editor or doing the copy/paste thing with an external editor. 

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
Reply
Loading...
Nov 19, 2017 0
Most Valuable Participant ,
Nov 19, 2017

Copy link to clipboard

Copied

I use Notepad++ too, but having to restart it each time is a PITA. I prefer

to copy and paste the code into the console and run it from there. To each

his own, of course.

On Sun, Nov 19, 2017 at 8:36 PM, Thom Parker <forums_noreply@adobe.com>

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
Reply
Loading...
Nov 19, 2017 0
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

I also spend a great deal of time copy/pasting to the Console, because most of my scripting is folder level. But for editing form fields and document scripts Notepad++ is great.

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
Reply
Loading...
Nov 19, 2017 0
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

I used to copy-paste from BBEdit to Acrobat, but sometimes it exceed the size limit (32 Ko I guess…) and the script is truncated.

This is why I asked about an external editor.

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
Reply
Loading...
Nov 19, 2017 0
Adobe Community Professional ,
Nov 19, 2017

Copy link to clipboard

Copied

Oh no, >32k :0

I've tried a number of editors and the problem with most is that they are slow on startup. You need something simple and fast.

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
Reply
Loading...
Nov 19, 2017 0
Adobe Community Professional ,
Nov 27, 2017

Copy link to clipboard

Copied

I use this folder level JavaScript to update my document level scripts. When I'm developing a document, I edit the script in Atom. I name the file the same as the PDF except with a .js extension and keep it in the same folder as the PDF. Then in my field or link properties, I use only calls to functions that are in the document level script. It makes editing super simple. When I need to update the script in the PDF, I just save it in my editor and then select "Inject Document JavaScript" from the Edit menu; no configuring the external editor, no copy/paste, no launching and relaunching the editor.

ppdf_trustedActiveDocs = app.trustedFunction(

    function () {

        app.beginPriv();

        var d = app.activeDocs;

        app.endPriv();

        return d;

    }

)

ppdf_trustedReadFileIntoStream = app.trustedFunction(

    function (sFileName) {

        app.beginPriv();

        var s = util.readFileIntoStream(sFileName);

        app.endPriv();

        return s;

    }

)

function ppdf_inject() {

    var jsFileName = this.documentFileName.split(".")[0]+".js";

    var jsPath = this.path.substring(0, this.path.lastIndexOf("/"));

    var jsStream = ppdf_trustedReadFileIntoStream(jsPath+"/"+jsFileName);

    var jsString = util.stringFromStream(jsStream);

    this.addScript("ppdf:init", jsString);

}

app.addMenuItem({

    cName: "PPDF_inject_javascript",

    cUser: 'Inject Document JavaScript',

    cParent: 'Edit',

    cExec: "ppdf_inject()",

    cEnable: "event.rc = (ppdf_trustedActiveDocs().length > 0) ? true : false;"

});

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
Reply
Loading...
Nov 27, 2017 2
Adobe Community Professional ,
Nov 27, 2017

Copy link to clipboard

Copied

I am amazed!

Thank you Joel_Geraci, such a good idea.

I will try your script asap.

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
Reply
Loading...
Nov 27, 2017 0