2011/03/06

Go from the current PDF page in DevonThink to the same page in Skim

I prefer reading my PDF files in Skim. Moreover all my read PDF files are inside DevonThink databases and all my PDF hyperlinks lead to DevonThink. As a result I regularly used the "Open in external viewer" function of DevonThink. Unfortunately the PDF is opened in the first page so you have to manually go to the desired page. If you need to do this a lot of times after a while it becomes annoying. So I wrote an AppleScript which automates this procedure :-).

The AppleScript is the following:
tell application "DEVONthink Pro"
    set pdfFile to the content record of the think window 1
    set RecordLink to the reference URL of pdfFile
    set PdfPage to current page of the think window 1
    set DevonThinkLink to RecordLink & "?page=" & PdfPage
    set the clipboard to DevonThinkLink
    set PdfPath to get the path of pdfFile
    set PdfPath to (POSIX file PdfPath) as Unicode text

   
   
    tell application "Skim"
        open file PdfPath
        set PdfPage to PdfPage + 1
        go document 1 to page PdfPage of document 1
    end tell
end tell

No comments: