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

TypeErrors in saveAs with Adobe Reader

Jesus
Registered: Mar 27 2007
Posts: 54

I have the following code in a folder level JS (not the only code):
app.beginPriv();
var myDoc = event.target;
 
myDoc.saveAs(path, formato);
 
app.endPriv();
})
 
It works OK woth Adobe Profesional but with Abobe Reader it gives me the following error:
 
TypeError: Invalid argument type.
Global.saveAs:18:XFA:topmostSubform[0].Page1[0].PrintButton1[0]:click
===> Parameter cPath.
 
I noticed that when using Adobe profesional, the variable myDoc is translated to "object Doc" but when using Reader it translate to "object Global". Maybe it has something to do with the problem.
 
Please help me!! Any Idea???

My Product Information:
Reader 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First, this function will only work in Reader if the document has "Save Rights". Do you have "Save Rights" on the PDF?

What version are you using? This function is considered an un-safe funtion. It could be used maliciously, but it's also very useful. So the restrictions on it have varied with just about every new version.

As for "event.target", this is context dependant. From where is it being called? I did a test script calling your function from a menu item and didn't have any problems on either Acrobat or Reader 8.1

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

Jesus
Registered: Mar 27 2007
Posts: 54
Thanks!

1- Yes the document has save right. I have tried two ways: 1- Using Adobe Pro Advanced, Enable Usage Right in Adobe reader, 2- Using a provider (Form Router)

2- i'm using Reader 7 and also Reader 8(not sure if is 8.0 or 8.1).

3- The funtion is coded in a folder level Java Script that is called from a button in the form.

Here is the complete .js:

/* saveAs Script */

mySaveAsjpg = app.trustPropagatorFunction(function(doc,path,formato)

{

app.beginPriv();
var myDoc = event.target;
myDoc.saveAs(path, formato);

app.endPriv();
})
myTrustedSpecialTaskFuncjpg = app.trustedFunction(function(doc,path,formato)
{
// privileged and/or non-privileged code above
app.beginPriv();
mySaveAsjpg(doc,path,formato);
app.endPriv();
// privileged and/or non-privileged code below
});
//

This is the instrucction in the button of the form:

MyTrustedSpecialTaskFuncjpg( this, "/c/chieftain/docs/" + FormId.rawValue + ".jpg" , "com.adobe.acrobat.jpeg");


Any advise please!!!!! I'm getting desesperate because this is stopping us from going to producction with my client and the client is very ofsset. I'm cosidering using Adobe Standard instead of Reader.

Waiting for your quiq response!! Will be very appresiated!!

jesus
Jesus
Registered: Mar 27 2007
Posts: 54
I downloaded Adobe Reader 8.1 and now Im getting this error message:

RaiseErrer: An unimplemented or obsolete function was called. Doc.saveAs

Any help will be appresiated.

Regards,

Jesus