This content has been marked as final. Show 16 replies
> myTrustedSpecialTaskFunc(this, "/c/jesus/mySavedDoc.pdf");
> Do you also have to specify the document name? If so how? Does "this." really work?
The value if "this" when the function is called is equal to the current document object, assuming it's called from a document event (or there's a document opened in Acrobat). That other parameter of that function is a file path that will be used to save the document.
Since you've set up the function as a trusted function, it can be called from a document event, for example the Mouse Up event of a button, which you would not be able to do otherwise.
The call that started the below mess:
// should allow priviledged calls to saveAs method
TrustFNsaveAs = app.trustPropagatorFunction(function(docvalue,saveFilename)
FNsaveAs = app.trustedFunction(function(docvalue,saveFilename)
// privileged and/or non-privileged code above
// privileged and/or non-privileged code below
Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0
Exception in line 1 of function top_level, script Field:Mouse Up
NotAllowedError: Security settings prevent access to this property or method.
App.trustedFunction:1:Field btn.form.save:Mouse Up
Do I have everything put in the right places? Can I use a variable to send data to the trusted function as a specified path?
Thanks and please advise.
What version of Acrobat are you using? Are you attempting this with Reader?
Am I doing something backwards?
> I want to be able to make this PDF in Pro and use it in Reader however.
Do you mean you want to be able to use saveAs in Reader? If that is the case, the form will need to be Reader Enabled in order to give Reader save rights.
Also, are you sure all of your code is in the JS file?
> App.trustedFunction:1:Field btn.form.save:Mouse Up
This error explicitly says that you are trying to call the App.trustedFunction method from the Mouse Up event on a button, which is not allowed. Any app.trustedFunction calls need to be in the folder-level JS.
Your code worked for me, though I did have to change one line to:
If I were you, I would reboot and try again. Note that for this to work for Reader, the form will have to be Reader-enabled.
> This error explicitly says that you are trying to call the App.trustedFunction method from the Mouse Up event on a button...
Actually, it indicates that the code was triggered by the Mouse Up event of the button, it does not indicate the location of the code that caused the error.
> Actually, it indicates that the code was triggered by the Mouse Up event of the button, it does not indicate the location of the code that caused the error.
I thought if it was from a folder-level script it shows the name of the file in the error - I can't test right now but I believe this is the case.
What I would do at this point is at least change the names of your trusted functions for security reasons. The reason that the saveAs method is not allowed to execute if the code is in the document is so that any old PDF that a user opens up can't saveAs itself without the user knowing.
You've decided to circumvent this security measure, which is fine, but you've also announced to the world that the FNsaveAs function can be used on your user's systems instead. This may not seem like a big deal since we are unlikely to know you or know who your users are, but you should ponder the possibilites.
Also, note that in this case the use of the trust propagator function is a bit superfluous since FNsaveAs does nothing other than call TrustFNsaveAs, unless you plan on calling it from other trusted functions.
Thanks! Already done.
Hello All -
I have followed the instructions that are listed above but I cannot seem to get this to run...
I receive the following error message:
Acrobat Database Connectivity Built-in Functions Version 8.0
Acrobat EScript Built-in Functions Version 8.0
Acrobat Annotations / Collaboration Built-in Functions Version 8.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 8.0
Acrobat Multimedia Version 8.0
Acrobat SOAP 8.0
TypeError: docvalue.saveAs is not a function
TypeError: docvalue.saveAs is not a function
How did you create the file you're trying to save? What code are you using to call the FNSaveAs function?
Thanks for responding...I figured it out. I had to change my code just a little bit...it was not finding the document object. I changed if from :
to this :
var myDoc = event.target ;
For the benefit of others, you need to use "event.target" to get a reference to the current document for PDFs created with LiveCycle Designer. For documents created with Acrobat, use "this".