Copy link to clipboard
Copied
Hello,
I have designed a form that uses Save function after filling the form... Form has been save as Adobe Reader Extended, but I have a problem to copy/move my trusted function to the JavaScript folder.
The form is going to be run/executed on a remote server that I have no control with and it is running by another company and Server is shared by a lot of other people. So asking to copy/move my trusted function to JavaScript forder the answer I am sure will be complete ignorance or maximum NO.
I wonder would there be a solution to this dilema bellow is the JavaScript.
------------
FormSaveAs = app.trustPropagatorFunction(function(oDoc,cPath,cFlName){
app.beginPriv();
try{
oDoc.saveAs(cPath + cFlName);
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
});
TrustedFormSaveAs = app.trustedFunction(function(oDoc,cPath,cFlName){
app.beginPriv();
cPath = cPath.replace(/([^/])$/, "$1/");
FormSaveAs(oDoc,cPath,cFlName);
app.endPriv();
});
------------
Regards,
JP
Copy link to clipboard
Copied
If you're asking whether the trusted function can be placed in a remote folder, then answer is indeed NO.
However, if you certify the file (a form of digital signature) then you could run this code from within the file itself, I believe. That's your only other option of doing it.
Copy link to clipboard
Copied
Hello,
Thank you all for taking your time and responding to my post, and I really appreciate that.
Well I solved my problem setting up my TrustedFunction after reading your advice and it works with no problem on my desk top but when I modify it and create a Reader Extended version and move it to the remote server... Does not work and gives me error as the time of saving and using my trusted function.
Here is where I need to save the filled form on this directory: \\idc.prod\psi-dfs001\ps_DB21\72088\Documents\AttachIt
And here is the path I have set in the Javascript;
var cPath = "/\\/idc.prod/psi-dfs001/ps_DB21/72088/Documents/AttachIt";
Adobe Reader shows "Error duing Save" no console dispaly etc even though I have check mark it on Prefrances.
I do have full authorithy to These folders and I have created the AtttachIt folder myself and I can save any document in it personnaly.
I have added the form and it's directory to Security Enhanced also the directory that I need to save the form after filling up.
This is my Path Setup: var cPath = "/\\/idc.prod/psi-dfs001/ps_DB21/72088/Documents/AttachIt/";
This is my File Name setup: var cFlName = "PHQ9(" + this.getField("LName").value + " " + this.getField("FName").value + " " +
formatDate(this.getField("Today_Date").value) + ").pdf";
This is my save as command: XFormSaveAs(this,cPath,cFlName);
and finally my Trusted function of SaveAs:
var XFormSaveAs = app.trustedFunction(function(oDoc,cPath,cFlName){
app.beginPriv();
try{
oDoc.saveAs(cPath + cFlName);
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
});
since the console does not get open I don't know what is wrong, can anybody help to see what is wrong as far as syntex is concerned?
Regards,
Jeff P.
Copy link to clipboard
Copied
Hello,
By trial and error and shooting in the dark I was able to solve my problem... I remove \//\ from my path and everything started working.
Now my path looks like this: var cPath = "/idc.prod/psi-dfs001/ps_DB21/72088/Documents/AttachIt/";
Thank you all for taking your time and looking over my problem.
Regards,
JP.
Copy link to clipboard
Copied
Put the code in the Javascript folder of the user.
Copy link to clipboard
Copied
Hello,
User does not have JavaScript folder, Application Reader is run for Multi State Users and each user does not have JavaScript folder...
Regards,
JP
Copy link to clipboard
Copied
Every user searches for a Javascript folder You can make the folder if it doesn’t exist. Still, a general “save anywhere” trusted function is a huge security hole, and if so were a company auditor I would reject it outright. The trusted function should grant least privilege. Also never use the same generic function name as other examples.
Copy link to clipboard
Copied
Hey, I am learning JavaScript so bear with me if I suggest something that is completely off-the-wall or is simply off the mark.
But I think what he is saying is that he has no way to know where the user folders are because it is handled at another remote location that he has no control of.
By that I think he is referring to trying to hard code the user folder path where this file should save itself into?
He is also using a custom SaveAs funtction.
See this note :
NOTE: When saving a file, it's very important to include the whole path. The doc.saveAs() function does not automatically use the path to the current file as a base.
MRahnemun, if this is what you're referring to see this guidance: https://www.pdfscripting.com/public/How-to-Save-a-PDF-2.cfm
You may want to look into where it says Acrobat Device Independent Format : https://acrobatusers.com/tutorials/file-paths-acrobat-javascript/
See this brief but to the point discussion : https://acrobatusers.com/forum/javascript/thispath-syntax/
Review creating a Custom SaveAs fucntion: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript/
And back to the basics here: https://acrobatusers.com/tutorials/folder_level_scripts/
Copy link to clipboard
Copied
Use the SDK Toolkit too: https://www.adobe.com/devnet/acrobat.html
Copy link to clipboard
Copied
If you're asking whether the trusted function can be placed in a remote folder, then answer is indeed NO.
However, if you certify the file (a form of digital signature) then you could run this code from within the file itself, I believe. That's your only other option of doing it.
Copy link to clipboard
Copied
Hello,
I tried that it works on only on the desk top but when I move/copy it to the Remote Server, gives an error at the time of saveas. using my trusted function within the Reader Extended Form. Please look at the continuation of this post that I have put again showing my server Directories etc.
Regards,
JP.
Copy link to clipboard
Copied
"Form has been save as Adobe Reader Extended"
It's unnecessary and counterproductive, unless your users are using Acrobat Reader X or earlier version.
Copy link to clipboard
Copied
Hello,
Yes the remote seerver only have Adobe Reader on the server because that is an Multi State wide server.
Regards,
JP.
Copy link to clipboard
Copied
Hello,
Thank you all for taking your time and responding to my post, and I really appreciate that.
Well I solved my problem setting up my TrustedFunction after reading your advice and it works with no problem on my desk top but when I modify it and create a Reader Extended version and move it to the remote server... Does not work and gives me error as the time of saving and using my trusted function.
Here is where I need to save the filled form on this directory: \\idc.prod\psi-dfs001\ps_DB21\72088\Documents\AttachIt
And here is the path I have set in the Javascript;
var cPath = "/\\/idc.prod/psi-dfs001/ps_DB21/72088/Documents/AttachIt";
Adobe Reader shows "Error duing Save" no console dispaly etc even though I have check mark it on Prefrances.
I do have full authorithy to These folders and I have created the AtttachIt folder myself and I can save any document in it personnaly.
I have added the form and it's directory to Security Enhanced also the directory that I need to save the form after filling up.
This is my Path Setup: var cPath = "/\\/idc.prod/psi-dfs001/ps_DB21/72088/Documents/AttachIt/";
This is my File Name setup: var cFlName = "PHQ9(" + this.getField("LName").value + " " + this.getField("FName").value + " " +
formatDate(this.getField("Today_Date").value) + ").pdf";
This is my save as command: XFormSaveAs(this,cPath,cFlName);
and finally my Trusted function of SaveAs:
var XFormSaveAs = app.trustedFunction(function(oDoc,cPath,cFlName){
app.beginPriv();
try{
oDoc.saveAs(cPath + cFlName);
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
});
since the console does not get open I don't know what is wrong, can anybody help to see what is wrong as far as syntex is concerned?
Regards,
Jeff P.
Copy link to clipboard
Copied
Hello,
By trial and error and shooting in the dark I was able to solve my problem... I remove \//\ from my path and everything started working.
Now my path looks like this: var cPath = "/idc.prod/psi-dfs001/ps_DB21/72088/Documents/AttachIt/";
Thank you all for taking your time and looking over my problem.
Regards,
JP.
Copy link to clipboard
Copied
Don't forget to mark your answer as correct.
Copy link to clipboard
Copied
Yes, that part looked strange... For future reference, the best way to find out the correct syntax to use for a file-path is to open it in Acrobat and then run this command from the Console window:
this.path;
It will output the full path of that file, and that's what you should use in your script.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more