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

Problem with saveAs(cPath) on Mac

EdGioja
Registered: Sep 26 2007
Posts: 25
Answered

I'm working with a MAC.

Could someone please tell me what is wrong with this?
No matter what I put in place of doclocation, I get the error on the saveAs line:

Value is unsupported. ===> Parameter cPath.

This works in Windows, but I can't make it work on the Mac.

app.beginPriv();
.
.
.
try{
doc.saveAs(doclocation);
} catch (e) {
for (var i in e)
console.println(i + ": " + e[i]);
}
.
.
.
app.endPriv();

I have tried using a file name in quotes.
I have tried slashes in both directions.
I have tried double slashes in both directions.
I have tried saving to a /Users/Shared location and a /Documents location.

I have tried doc.saveAs({cPath: doclocation});

Can someone please point me in the right direction?

Thank you.

My Product Information:
Acrobat Pro 8.1.1, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This is the error you get when the path name does not end with ".pdf". There are also many other reasons why this function might fail. For one thing, it's a privileged operation and requires Save Rights to work in Reader. There are also several locations where a file cannot be saved. Look up "Safe Path".

It's a bit bothersom that it's working in Windows. It could be path or excution context differences between the systems. Are you running this from the Console Window? Does it display the file save dialog when you do not include the path parameter? Are you trying to save to itself?

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

EdGioja
Registered: Sep 26 2007
Posts: 25
Thank you for your response. Actually, I JUST figured out the issue...the slashes are backwards on Mac (I guess they are backwards on Windows if you are a Mac person).

Anyway


In Windows, I create the cPath as

var cFilename = mylocation + "\\" + mySubdirectory + "\\" + myfilename

in MAC, the cpath is

var cFilename = mylocation + "\/" + mySubdirectory + "\/" + myfilename


I can't tell you how many hours I spent trying to figure this out. Oh well, live and learn I guess.

Thanks again.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ahh, you didn't read the part of the reference about Device Independant Paths. All paths in Acrobat JavaScript are the same, regardless of whether it's a PC or a Mac.
See this artical:
http://www.acrobatusers.com/tutorials/2007/js_file_paths/

But for Windows, Acrobat is kind and takes a Windows path. That's why it worked.

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

EdGioja
Registered: Sep 26 2007
Posts: 25
Yep, I must have missed that one.

While we are talking about documentation, though, is there a place that will tell me how to create a command-key shortcut on the Mac? (I can start a new thread if you would prefer). In Windows,

addMenutItem({ ... cUser: "M&y Shortcut" ...})would make the y an Alt+Y shortcut. What is the Mac equivalent?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The syntax you suggest should work for creating shortcuts when the menu is active.

Unfortunately the only way to create Global Acrobat shortcuts is with a plug-in. But I have actually used a plug-in to create shortcuts to JavaScript functions. It's really effective, but not very practical, there are only so many shortcut key sequences around and Acrobat has most of them locked up.

You'll find information about the Acrobat SDK for building plug-ins at:
http://www.adobe.com/devnet/acrobat/

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