Thanks to some help from @Test User Name and @Gilad D, I have been able to get my original problem about 90% of the way fixed. I now need to tie everything together in order to solve this conundrum. That conundrum is calling Acrobat from an InDesign script on a Mac.
Windows users have no trouble at all, since BridgeTalk is available for their use, allowing them to call Acrobat directly from an InDesign script. Mac users, on the other hand, have been shortchanged by Adobe. BridgeTalk does not work with Acrobat on a Mac. Unfortunately, where I work, I have found myself in the unenviable position of requiring an InDesign script (written in JavaScript/ExtendScript) to call Acrobat to perform a simple page-replace function. And, of course, our computers here at work are all Macs.
With the help of the aforementioned people, I have, at least, gotten most of the way there. I've discovered that AppleScript can be used to call Acrobat and do things. And there is a "doScript()" function available to JavaScript, which allows scripts of a different language to be run inside of a JavaScript script. Sadly, I ran into a wall when having AppleScript save a file, but at least I can have it call a JavaScript folder-level script function to take care of it for me, which I have verified to work. Yeah, you can see the complications here.
So, what has to happen, then, is a JavaScript script that calls an AppleScript script, which, in turn, calls another JavaScript script that runs inside of Acrobat. Whew! Talk about a script-ception! But I've actually been able to make this work! However, I've run into a small snag.
You see, I need to pass a variable through all three layers of scripts in order to get this to work. I'll post what I have so far.
First, the top-level script, which runs inside of InDesign. This is just a test script to make sure it all works before I integrate it with the real InDesign script:
var fName = "testfile2.pdf";
var aFName = new Array;
aFName.push(fName);
scriptFile = new File ("/apache HD/Users/apache/Documents/unlockCover.applescript");
app.doScript(scriptFile, ScriptLanguage.APPLESCRIPT_LANGUAGE, aFName);
Now, on to the AppleScript file (the middle layer), which you can see being called above:
on run argv set unlockedFile to item 1 of argv as text tell application "Adobe Acrobat Pro" do script ("unlockCover(" & unlockedFile & ");") end tell
end run
This should, theoretically, finally call the last script (bottom-level), which is a JavaScript file saved inside of the folder-level area for Acrobat, so that it runs automatically upon Acrobat launching and the function stays in memory to be called at any time:
var unlockCover = app.trustedFunction(function (fName){ app.beginPriv(); var myDoc = app.openDoc("/g/ ArtDept/Product Templates/ ProofCover/proof_cover.pdf"); myDoc.replacePages(0, "/apache HD/Users/apache/Desktop/Old samples/407471 Folder/407471_cover.pdf", 0, 0); myDoc.saveAs("/apache HD/Users/apache/Desktop/" + fName); myDoc.closeDoc(true); app.endPriv();});
There's the real meat of it. Those four lines between "app.beginPriv();" and "app.endPriv();" are the ones that this whole thing is all about. However, I receive an error message when I attempt to run the top-level script:
Expected end of line but found application constant or consideration.
So I'm sending a call out to all of you scripting gurus out there how I can put the final nail in the coffin of this monster and call it a day. I'm almost 100% certain that the problem lies in trying to pass the argument ("aFName" in the top-level script) to the mid-level AppleScript script. Any ideas?