2011/02/21

Automated summary creation linked with the source PDF file

One of the great characteristics of Skim highlights is that they capture automatically the highlighted text  in a newly created note.


Moreover you can export these notes in a separate txt or rtf file.




As a result an approximation of a summary is created if you highlight the appropriate text passages.




Additionally if you have created the Skim notes with the DevonThink links as I described in the post "DevonThink links in Skim notes and AppleScript" you can use another AppleScript in order to have a properly formatted hyperlink from every highlighted text to the exact pdf page of the paper or book.


When you copy this text to the respective wiki page of the paper or book you will have a nice hypertext between your summary and the source pdf file.


You can see the seamless integration between the summary and the pdf in the following YouTube video.

The AppleScript code is the following (updated):

 tell application "Skim"
    set pdfDevonThinkLink to (get text for note 4 of page 1 of document 1) as string
    set pdfDevonThinkLinkWihtoutZero to (text 1 thru ((length of pdfDevonThinkLink) - 1) of pdfDevonThinkLink) as string
  
    set allMyPages to pages of document 1
    set numberOfMyPages to length of allMyPages as integer
  
  
    tell application "TextMate"
        activate
        tell document 1
            insert "===Skim notes===
"
        end tell
    end tell
  
    repeat with currentPage from 0 to numberOfMyPages
        set pageNotes to notes of page currentPage of document 1
        set numberOfPageNotes to length of pageNotes as integer
      
        repeat with currentNoteNumber from 1 to numberOfPageNotes
            set pdfText to (get text for note currentNoteNumber of page currentPage of document 1) as string
          
            set pageForDevonThinkLink to currentPage - 1
            set the clipboard to pdfText
          
            tell application "TextMate"
                tell document 1
                    insert (the clipboard) & " [" & pdfDevonThinkLinkWihtoutZero & pageForDevonThinkLink & " p. " & currentPage & "]

"
                end tell
            end tell
        end repeat
    end repeat
end tell
In order for the script to work you need to have TextMate installed in your Mac and an empty txt file open.

No comments: