Zettelkasten Forum

Extract Comments from PDF via Script

edited January 10 in Software & Gadgets
This discussion was created from comments split from: Sample Note - open to suggestion for improvements.

It is a reply to @ndpi's request for @achamess's PDF script.

Author at Zettelkasten.de • http://christiantietze.de/


  • @ndpi, I've written a few scripts that extract PDF highlight annotations from Papers 3:

    These could maybe serve as examples or starting points for you. For more info on how to script Papers 3, see Scripting Papers 3 for Mac with AppleScript – A Getting Started Guide.

  • @ndpi, and here's a script that copies formatted references and citekeys (in MultiMarkdown format) to the clipboard:

    -- For all publications selected in Papers 3, copies their citekey and
    -- formatted reference to the clipboard
    tell application id "com.mekentosj.papers3"
        set selectedPubs to selected publications of front library window
        set outList to {}
        repeat with aPub in selectedPubs
            set pubCitekey to citekey of aPub
            set pubReference to formatted reference of aPub
            copy "[#" & pubCitekey & "]: " & pubReference to end of outList
        end repeat
        set the clipboard to my mergeTextItems(outList, linefeed & linefeed)
        display dialog "Copied info for " & (count of selectedPubs) & " publications to the clipboard." buttons {"OK"} default button "OK" with icon 1
    end tell
    -- Merges the given list of text items using the given separator string
    on mergeTextItems(textItemList, aSeparator)
        considering case
            set prevTIDs to text item delimiters of AppleScript
            set text item delimiters of AppleScript to aSeparator
            set mergedText to textItemList as text
            set text item delimiters of AppleScript to prevTIDs
        end considering
        return mergedText
    end mergeTextItems
  • @msteffens This is very helpful, thank you! AppleScript is still somewhat of a strange beast to me - and I've worked as a professional software engineer.

  • @ndpi I highlight in Skim.app and then extract to Sublime ZK.
    Here is the script. I can't promise it still works. But give it a try. It's pretty amateurish but it gets the job done for me.


Sign In or Register to comment.