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?
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