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.
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.
Copy link to clipboard
Copied
Has anyone ever managed to use an external editor on MacOS?
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.
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>
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.
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>
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.
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.
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.
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;"
});
Copy link to clipboard
Copied