简体   繁体   中英

Opening pdf using Acrobat Javascript on Apple

I would like to open a pdf document using Javascript in Acrobat Pro DC running OSX. Here's what I see:

app.openDoc("~/Desktop/test.pdf")
Invalid Location "~/Desktop/test.pdf". File or folder does not exist.
NotAllowedError: Security settings prevent access to this property or method.
App.openDoc:1:Console undefined:Exec
undefined

I wonder whether the error is the security restrictions mentioned on page 135 of the Javascript for Acrobat reference .

Because Acrobat JavaScript is cross-platform, you need to use device independent paths and you can't use device-specific shortcuts like "~". Something like the examples below.

Windows Path C:\\MyFolder\\MyFile.pdf

app.openDoc("/C/MyFolder/MyFile.pdf");

Macintosh path MyDisk:MyFolder:MyFile.pdf

app.openDoc("/MyDisk/MyFolder/MyFile.pdf");

You can use "../" for relative paths.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM