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

Problems with saveAs

drostron5
Registered: Apr 18 2008
Posts: 2

I wonder whether anyone can help me with the following problem. I've been pulling my hair out for 3 days now.

Basically I have produced a script that places a button on the Reader 7 toolbar. When clicked I want the button to save the current document to a folder on my C drive. Sounds pretty easy? Not really.

I keep getting the error "TypeError: Invalid Argument Type" whenever the saveAs code is called.

I've listed my code below. The document I am using has save rights and the folder exists on my C drive.

Can anyone help???

PS - I am using the free version of acrobat reader downloaded from Adobe website.

// add a toolbutton
app.addToolButton({
cName: "myToolButton",
cExec: "trustedNewDoc()",
cTooltext: "Email or Fax Document",
cLabel: "Communicate"
});

trustedNewDoc = app.trustedFunction( function ()
{
// Additional code may appear above
app.beginPriv(); // Explicitly raise privilege
try {
app.alert("In function")
this.saveAs ("/C/DavidTemp/Me.pdf");
}
catch (err) {
app.alert("Error: " + err);
}
app.endPriv();
// Additional code may appear below.
})

My Product Information:
Acrobat Standard 7.0.9, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are a couple of issues that could be causing this exceiption.

1. The file path doesn't exist, or is not considered a Safe Path.
2. The file has not been enabled for Reader "Save" Rights

If you were using Reader 8, you'd get a security exception for either of these issues.

I suspect that your issue is with #2. This is a tricky one. You can enable for file save using Acrobat 8 Professional. Which will work for saving filled in forms.

In Acrobat 7 Professional you can Reader Enable for "Commenting" Rights, which will allow you to use the SaveAs function for a document that has had comments added to it, but fill in a form field and the function won't work.

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

mark_poston_mekon
Registered: Apr 16 2008
Posts: 15
Hi,

This is the same requirement that I have.

Basically, the saveAs function cannot be used with a file path except in batch or console modes. Making a trusted function and raising the privileges will not work either :(

The point of both of our requirements seems to be that we need to automate the save and not rely on the user saving the file to the correct location ... that's certainly mine anyway :)

Kind regards

Mark Poston
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Using a trusted function does work. If you are having a problem, then there is some other issue.

For example, you say that you don't want the user to have to select the save location. If this means that you put a Save button on the form, then that's an issue. Trusted fucntions can't be defined from an un-trusted location, i.e. a document script.

Please provide details for the issue you are having.

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