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

Saving with javascript after adding security

ACat299612
Registered: May 31 2011
Posts: 14
Answered

I have a javascript that adds a watermark, then adds security via the encryptUsingPolicy command. When I go to save the document using a privledged function, I get an error and cannot save. Do I need to do something different to save a document after applying security?
 
Thanks

try67
Expert
Registered: Oct 30 2008
Posts: 2401
Is this running inside an Action (you posted in the Action forum...)?
What error are you getting? What code are you using?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ACat299612
Registered: May 31 2011
Posts: 14
Sorry, I think I may have posted this in the wrong forum. I am running this from a standard javascript. I use the try statement with a catch, and the catch is being executed, so I am not sure what error I am getting.
try67
Expert
Registered: Oct 30 2008
Posts: 2401
So either remove the try-catch clause, or use the exception object to print the error message to the console.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ACat299612
Registered: May 31 2011
Posts: 14
The error I get is as follows:
RaiseError: This file must be saved with a full save.
try67
Expert
Registered: Oct 30 2008
Posts: 2401
Can you post your code?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

ACat299612
Registered: May 31 2011
Posts: 14
Here is the saveas code:
var mySaveAs = app.trustedFunction(
function(oDoc,cFlName)
{
app.beginPriv();
try{
oDoc.saveAs({cPath: cFlName,
bCopy: true});
}catch(e){
app.alert("Error During Save");
}
app.endPriv();
});
try67
Expert
Registered: Oct 30 2008
Posts: 2401
Accepted Answer
My guess is that the problem is with the bCopy parameter. Is there a reason why you're using it?

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4311
Why are you not showing the error message text as part of the alert?

function(oDoc,cFlName)
{
app.beginPriv();
try{
oDoc.saveAs({cPath: cFlName,
bCopy: true});
}catch(e){
var cMsg = "Error During Save\n";
if (app.viewerVersion < 6) {
cMsg += e.toString();
} else {
for (i in e) {
cMsg += i + ": " e[i]) + "\n";
}
app.alert(cMsg, 0, 0);
}
app.endPriv();
});

What is the code that is calling this function?

George Kaiser

ACat299612
Registered: May 31 2011
Posts: 14
The bCopy was in there from an earlier version. I made some changes to the code and never took it out. Turns out the bCopy was the problem, and all is working now!!! Thanks for your help!!!