These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

NotAllowedError trustedFunction

lucaso
Registered: Feb 5 2008
Posts: 49

Reader 8 is driving me nuts... I've read that one should put trustedfunctions in a folderlevel .js, but that means I will have to distribute it, and having clients install it using a installer supplied by me. Reader 7 does not give these problems, as far as I know. Stubborn as I am, trying to make these simple functions work in Reader, by putting these trustedfunctions in the PDF itself.

function CleanAnnot() { app.beginPriv(); if (pn > -1) var ant = this.getAnnot(pn,dest); if (ant != null) ant.strokeColor=color.white; app.endPriv();}

trustedCleanAnnot = app.trustedFunction(CleanAnnot);

In Acrobat 7: what does the debugger say: trustedCleanAnnot is not a function!
In Reader 8: NotAllowedError !!
It does not make any differences in en/disabling the JavaScript options in Reader.
If I have to distribute the folderlevel script, do I have to make trustedfunctions? Seems to me it already will be trusted.
And is this really the only solution out of this mess?

although pushing towards senior age, still want to keep up the pace

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I think that "NotAllowedError" is pretty clear. The function or property it's complaining about is not allowed to be used in the given context. Acrobat 7 is the same as Acrobat 8 in most respects, Acro7 just isn't complaining about the trusted function. But it has the same problem.

Reader has a lot of restrictions on it, which is why it's free. In fact, if you look in the Acrobat JS Ref, you'll find quite a few operations that simply cannot be done in Reader, and others that require a privileged context. This is how it works. If it says it's restricted in the Ref, and then you try it, and yes indeed, it doesn't work in Reader, then it doesn't work.

However, none of the operations in your trusted function require privilege. You don't need the trusted function. To chage an annotation's stroke color in Reader, all you need is Comment Enabling on the document.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

lucaso
Registered: Feb 5 2008
Posts: 49
Hi, Thomp, I checked the Reader-properties for this document. In Acro7 it has commenting enabled, opening it in Reader 8 "commenting: not allowed". I cannot find out how to enable it in Reader, looks to me I will be needing the Reader Extensions. What I can do is rewrite the JS scripts to check for Reader, and if so, skip these functions: in Reader the NotAllowedError just stops the whole function, not very forgiving, is it?
Checked th JS guide, but I cannot figure out how to enable the commenting in Reader without the Extensions. Weirdly enough it seems that Acro Pro gets crippled by it if installed. Or should I insert Collab.showAnnotToolsWhenNoCollab = true; ?

although pushing towards senior age, still want to keep up the pace

lucaso
Registered: Feb 5 2008
Posts: 49
hi Thomp,
I eventually found how to enable comments (and analysis) for Reader...
And... it works. Was not mentioned in the F1 help.
Thanks for putting me on track.

although pushing towards senior age, still want to keep up the pace