2011/05/20

Sync PDF page numbers between Skim's snapshot window and main window.

A quite useful feature of Skim is that "you can take "snapshots" of important sections (like the bibliography section) of a PDF document, to keep them on your screen for easy reference. This way you don't have to leaf back to the section every time you want to see it" (Skim help file).

But the snapshot windows are just for viewing the material. For example, you cannot highlight or select text in them. In order to make annotating of these pages easier I wrote an AppleScript, which instantly shows you in the main window, the current page in the snapshot window. When you finish annotating this page you can go back to the previous page by using the cmd + [ shortkey or by triggering the corresponding gesture (I use the "three finger left" gesture for this task).

If you use more than one snapshot windows from the same document, after selecting the page that you want to annotate in one of them, you need to click one time all the remaining snapshots windows, before running the AppleScript.

The AppleScript code is the following:

--2011-05-20
--http://organognosi.blogspot.com

set nameSnapshot to ""
tell application "Skim"
    set frontNameDocument to name of document 1
    set windowsNames to get the name of windows
   
    repeat with x from 1 to count of items of windowsNames
        set windowName to item x of windowsNames
        if windowName contains frontNameDocument & " —" then
            set nameSnapshot to windowName
        end if
    end repeat
   
    set position to offset of "—" in nameSnapshot
    set AppleScript's text item delimiters to ""
    set stg_numberPage to characters (position + 7) thru -1 of nameSnapshot as text
    set numberPage to stg_numberPage as number
   
    go document 1 to page numberPage of document 1
   
end tell

No comments: