I want to open a PDF document at a specific page from the command line, sort of like vim +n [file] . Is there any way to do that in OSX, with any PDF reader program?
asked Jan 13, 2010 at 15:04 45.2k 52 52 gold badges 160 160 silver badges 259 259 bronze badgesYou can do this with Evince using the -p or --page-label=PAGE command line argument like so:
evince -p 5 foo.pdf
answered Jan 13, 2010 at 15:16
7,361 2 2 gold badges 26 26 silver badges 35 35 bronze badges
I kept getting errors from Julio's answer. With the current Version 1.4.6 (80) of Skim and OSX Mountain Lion (10.8.5), the following code worked for me. I think the issue might be that pageNum has to be treated as an integer, but it gets parsed in as a string. This code assumes you have Skim installed.
on run argv set fileName to (item 1 of argv) set pageNum to (item 2 of argv) as integer tell application "Skim" open fileName tell document 1 to go to page pageNum activate end tell end run
Skim still needs an absolute filename. So you would run it with the same command mentioned in Julio's answer. osascript gotopage.scpt "/full/path/to/doc/mydoc.pdf" 99