Skip to main content
tpk1982
Legend
Oct 25, 2016 11:53 AM UTC
Question

saveAs in Mac

HI,

I am trying to saveAs the opened pdf in my server. Before the sever address i tried to save the file in desktop but it is not working. Could you please suggest me?

this.saveAs("/Macintosh HD/Users/kk/Desktop/xxxxx.pdf");

app.closeDoc();

another method:

this.saveAs("~/\Desktop/\/xxxxx.pdf");

app.closeDoc();

I read this articles but not able to solve

https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

https://acrobatusers.com/tutorials/file-paths-acrobat-javascript

Thanks,

K

This topic is closed to new replies. Start a new post to keep the conversation going.

18 replies

Legend
Oct 26, 2016 12:15 PM UTC

I think you may be using the console the wrong way. ENTER only runs the current line, unless you select the text first.

You you can put a function call on a button but the function definition must be in a startup script. This is a vital security protection. I suggest too that you use an entirely unique name for the script, never copy the name of a model.

Translate
Karl Heinz  Kremer
Community Expert
Community Expert
Oct 25, 2016 1:42 PM UTC

When you use a Unix style path on a Mac, the "Macintosh HD" portion of the path is not used. Try using this:

    this.saveAs("/Users/kk/Desktop/xxxxx.pdf");

Keep in mind that you need to do this from within a privileged context (see here for more information: Acrobat DC SDK Documentation - Doc.saveAs()

Translate
tpk1982
tpk1982Author
Legend
Oct 26, 2016 7:25 AM UTC

Hi try67,

When i try to run in console it shows error like below

@Karl: I tried with this.saveAs("/Users/kk/Desktop/xxxxx.pdf"); but same error occurs

Regards,

K

Translate
try67
Community Expert
Community Expert
Oct 25, 2016 12:23 PM UTC

What happens when you run this code? Also, from where are you running it?

And app.closeDoc(); is not a valid command. the closeDoc method is a part of the Document object. Use this instead:

this.closeDoc();

If you want to know the correct syntax for the file-path of a specific file, open it in Acrobat and then execute this code in the JS Console:

this.path;

It will print out the full path of current file, in the syntax that you need to use in your code.

Translate
tpk1982
tpk1982Author
Legend
Oct 25, 2016 12:57 PM UTC

Hi try67,

Thanks for your reply. Nothing happen. I am using this script with SUBMIT button. While i am pressing i need to save a copy of file to specific path.

Yes i tried the app.alert(this.path) method to know the location and used the same in the code (

  1. this.saveAs("/Macintosh HD/Users/kk/Desktop/xxxxx.pdf"); 

)

Thanks,

Karthi

Translate
try67
Community Expert
Community Expert
Oct 25, 2016 1:23 PM UTC

You can't use this command from a button just like that. It needs to run from a trusted context, e.g. a folder-level script.

If you check the JS Console (Cmd+J) you'll see an error message there saying that the method failed for security reasons.

Translate