This only seems a simple task because you don't understand it yet!
The error means: you cannot do this the simple way you want, you need a folder level script to define a privileged routine. Yes, you do and you must use a folder level script, like everyone else with the same problem.
Folder level scripts can be used to define privileged routines, which can do the things which are otherwise forbidden. This is the only place you can define them.
The routines can take parameters, so there is no problem with your predefining a routine which does an openDoc.
Now, hopefully this will help you make more sense of the talk of privileged functions in the documentation.
By the way, I don't know whether this will return the doc object, as it isn't clear to me from the documentation whether you will be executing in a batch, console or menu event. Be sure to detect and report an NULL return from openDoc. Read more under "return value".
Honestly, it doesn't help. Except for the fact that you are making it abundantly clear that, in order to use the app.openDoc method, I MUST put it in a folder-level script. Fine. I have done that and it still didn't work, as I mentioned in a reply to my other post. I'm sure I'm just missing something trivial, though.
As for what it returns, it appears to return a Doc object which I can assign to a variable, of course, but for now, I'd be happy with it just opening the document at all. One step at a time, that's how I roll.
Put a document on folder temp of the c drive and execute following in the debugging console:
Sorry, @Bernd Alheit, I'm working on a Mac, not Windows. And even if I was and had done what you suggested—which is pretty much the same thing I've been doing—I'd still get the same message. Whether I assign it to a variable or not, the result is the same.
Also, try opening a local file on your desktop, in case the network location or spaces upset it.
That is, Acrobat DOES refuse to open files from certain locations based on ill-documented rules. Hence the suggestion to open specifically a local file from a safe place.
My guess is the path you're using is incorrect. Try opening the file
manually and then running from code from the JS console:
See if the result is identical to the path you're trying to open...
PS - There are no limitations on the file path when you try to open it,
only when you try to save a file under a new name.
@Gilad D, you are a genius.
I'm still relatively new to Macs and their file structure, so this one made me facepalm a bit. It turns out that the filename I had going on ("/Volumes/g/ ArtDept/Product Templates/ ProofCover/proof_cover.pdf") was too much. I had to remove the first level, making the result: ("/g/ ArtDept/Product Templates/ ProofCover/proof_cover.pdf"). When done this way, the script works perfectly. I shall definitely remember that "this.path" property for future reference!