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)
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.
When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.
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