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.
})
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