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)
The Apple Support Community will permanently close on November 20, 2026. Starting today, the site will no longer accept new posts and is available in a read-only state.
You can continue to find trusted guidance and support on the official Apple Support site.
We want to thank the community members who have contributed their time and expertise to help others with their Apple products.
The Apple Support Community will permanently close on November 20, 2026. Starting today, the site will no longer accept new posts and is available in a read-only state.
You can continue to find trusted guidance and support on the official Apple Support site.
We want to thank the community members who have contributed their time and expertise to help others with their Apple products.
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)
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
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
Ah, yeah, that's much easier. 🙂
If using Acrobat then the PDF file has initial view preferences that you can set… Page to view being one of them…
I am completely new to OSX and Apple
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