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

this.saveAs()

drosales
Registered: Jun 3 2011
Posts: 25

Hello,
 
i have a pdf and from the console window i try to run "this.saveAs("C
:/Users/Dan/My Documents/this.documentFileName");
 
this is the error i get:
UnsupportedValueError: Value is unsupported. ===> Parameter cPath.
Doc.saveAs:1:Console undefined:Exec
 
i want to create button with a script that will save my pdf with the same naem in "My Documents" folder.
why wont this work?
 
Daniel-

My Product Information:
Acrobat Pro 10.0.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Two problems.
- The path you're using is not in valid syntax.
- Running saveAs from a button (I'm assuming you're talking about a form button) is only possible with through a folder-level script.

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

maxwyss
Registered: Jul 25 2006
Posts: 255
saveAs() does require a file name extension, which is missing.

On the other hand, it looks as if you want to save the file to a specific directroy, but using the same file name as the open document has. in this case, the path string is incorrect, as it appears to be a plain string.

You'd have to assemble the path like this:

this.saveAs(C/Users/Dan/My Documents/"+thisl.documentFileName)

You might also have a closer look at the entry for saveAs() in the Acrobat JavaScript documentation.

Hope this can help.

Max Wyss.

drosales
Registered: Jun 3 2011
Posts: 25
Actually,

my test works fine in the console window if i replace "this.documentFileName" with "test.pdf".

i was trying to create a toolbar button. i placed my script in a doc level js and i get a floating toolbar with the button. You said its only possible through a folder level script. what if i placed it in a trusted function and gave it privelidge with app.beginPriv()....in the doc level js?

what is the valid syntax?

thanks-
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The code in Max's post should have been:

this.saveAs("/C/Users/Dan/My Documents/"+this.documentFileName)

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

drosales
Registered: Jun 3 2011
Posts: 25
sorry guys, but neither of the examples worked. this is my code:


var cFinishPath = "/C/Users/Dan/My Documents/";
var cFinishName = this.documentFileName;

app.addToolButton({
cName: "myToolButton",
cIcon: "icon",
cExec: "myFunc();"
cTooltext: "Save",
cEnable: true,
nPos: 0
});


//var myFunc = app.trustedFucntion(
function myFunc(){
//app.beginPriv();
app.alert("Got this far",3);
this.saveAs("/C/Users/Dan/MyDocuments/" + cFinishName);

//this.saveAs(cFinishPath + this.documentFileName);
//app.endPriv();
};
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can't use the "this"-object in your folder-level script. You need to pass the name of the document as a parameter to your trusted function.

- 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: 4307
Maybe you need to start by reading How to save a PDF with Acrobat JavaScript by Thom Parker.Note the "oDoc" parameter is the document object, usually "this" but it could be different if you opened a PDF using JS and assigned a different object name to the opened PDF.

"cMyPath" is the device independent file path name.

"cFlName" is the file name including the ".PDF" extension.

George Kaiser

drosales
Registered: Jun 3 2011
Posts: 25
Thanks guys. i'll read that article and update you later. have a great weekend!

Daniel-