You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to open a PDF file to a specific page

I'm wondering if Preview (which I don't think can) or Adobe Acrobat (which I think can) can be scripted to open a PDF file to a certain page. Either on 10.7 or 10.6


Thanks

iMac, Mac OS X (10.6.8)

Posted on Jul 26, 2011 9:05 PM

Reply
5 replies

Jul 27, 2011 4:05 AM in response to Eric Dannewitz

neither acrobat nor preview are directly scriptable. best you can do is some GUI scripting:


set newPage to 25


tell application "System Events"

tell process "Preview"

set frontmost to true

tell menu bar 1

tell menu "go"

click

tell menu item "Go to Page…"

click

end tell

end tell

end tell

tell window 1

tell sheet 1

tell text field 1

set value to (newPage as text)

end tell

tell button "OK"

click

end tell

end tell

end tell

end tell

end tell

Jul 27, 2011 4:16 AM in response to Eric Dannewitz

Twtwtw's script requires that you enable access for assistive devices in the Universal Access System Preference pane. You could avoid that with the following script:


set theFile to choose file of type "pdf" with prompt "Please choose a PDF file."


display dialog "Enter the number of the page you want to go to." default answer "" buttons {"Cancel", "OK"} default button 2

set thePageNumber to text returned of result


tell application "Finder"

open theFile using alias "Macintosh HD:Applications:Preview.app:"

end tell


tell application "Preview" to activate

tell application "System Events"

keystroke "g" using {option down, command down} -- ⌥⌘G

keystrokethePageNumber

delay 1

keystrokereturn

end tell

Oct 25, 2011 8:37 AM in response to Eric Dannewitz

I am completely new to OSX and Apple


, but am giving my first attempt at Apple Script. I know that Acrobat and Adobe Reader have Open Parameters built in that they say in their documentation(link page 5) can work, im just not sure how to add the options to the Apple Script. Right now I have:


tell application "Adobe Reader"

open file "My:Path:myFile.pdf"

end tell


Any help would be awesome.

Thank you,

James


PS I forgot to add these Open Paramaters you can just add page=5(or whatever page you want) to have the pdf open to that page.

Applescript to open a PDF file to a specific page

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.