Stream annotations from your PDF reading sessions with DEVONthink

I guess each electronic device should ship with sufficient supplies. Even an Apple TV or Apple Watch can drive me nuts :grinning:


Ha. I remember the first time suddenly seeing a different (and very ugly) “complication” on the watch. It took me a lot of swear words and time to figure out to get back to the one I wanted.

I didn’t want to start a language war (since that’s quite useless, like debating about the merits of vi vs. Emacs). My intention was only to let @mlevison know that they’re not limited to a possibly head-ache-inducing language but can use another one (which other side effects, of course, like addiction to parenthesis).

My occasional curses regarding developers in general (kind of ironic, I know) and Apple in particular always make my wife smile :wink:


I’m building a script that can sync and merge PDF annotations. Looking into the modificationDate parameter of PDF annotations it seems that it’s actually more a creationDate. It seems that annotations of type Highlight or Popup (“Notes” in DT) only set the date on creation, but not when changed (e.g. when changing the contents of a note). Would you know if that is true @cgrunenberg?

1 Like

DEVONthink doesn’t explicitly change the dates on its own but this seems to be the way the PDFkit handles them. Do other PDF editors change the date after modifying an annotation?

Don’t know I want to know about other editors, but I’m following whatever PDFkit does here.

I was just curious what’s the common approach and whether DEVONthink should update the date on its own.

Heh. Well, I thought that taking annotations front-to-back would be sufficient, but it finally happened: I tripped myself up with the front-to-back heuristic.

This weekend, I read through and annotated an article, failing to realize that I had added a highlight to the article’s conclusion in the past. My beautiful stream annotations workflow therefore produced a few extracted notes—mostly of the same annotation! D’oh.

This morning I played around with some options for interacting with each annotation via AppleScript. Sadly, there aren’t many: I could open the file in other apps, but that makes the automation more complicated and less invisible. It seems like the best solution is to get down to ASObjC and use the metadata there.

Fortunately, I just lucked into a solution for the problem I reported a few weeks ago.

So, my next script-project will be building out a way of streaming annotations in the order they’re added. @cgrunenberg, since I was grateful you warned us of your Sherlocking plans last week, please let me know if summarize-highlights-in-the-order-annotations-are-added is also something you’re plotting to do. :laughing:

(That’s not necessarily a feature request… I don’t think it’ll be too hard to do with scripting!)

1 Like

I haven’t seen any other features or workflows using annotation date modified, so I would be surprised if another PDF app developer concerned themselves with this.

No such plans currently :slight_smile:

1 Like

Not sure what you’re looking for, but here’s the workflow I’ve build with ASObjC which is working fine at the moment:

  1. Extract annotations+comments from Markdown (using regexes)
  2. Extract annotations+comments from PDF (using @pete31’s script - adapted)
  3. Combine annotations + comments in one array
  4. Search PDF for each annotation in array (using findString)
    • If annotation found at x,y:
      • Update comment of existing annotation
      • Add x,y position of existing annotation in array
    • If annotation not found:
      • Create annotation with comment
      • Add x,y position of new annotation to array
  5. Sort combined array based on page number, y position, x position
    • Items without page number, x or y (meaning: not found) are first in the array
  6. Write sorted annotations to Markdown file with the proper Markdown formatting

The array saves for each annotation metadata where it found the annotation to begin with and whether it matched in markdown, pdf or both.

This means annotations are always in the right order (of the document) based on their x,y position. If this workflow would be helpful, I’d be happy to share the scripts (posted bits earlier).


I think DT should just follow PDFkit and not do things which are then unique to DT (although I would love for PDFkit to change this behavior, but I don’t count on it)

This is wild. You should do a demo video or something to show this off, as it sounds unbelievable!

I like my notion of reading sessions, though, so I’ll keep building out what I’m trying for here.

I didn’t have much time to do a full recap, but I might in the future. Here’s a quick peek of what it does now: 2022-05-19 DEVONthink 3 Resources save content — YouTube Coming to Apple TV - Apple 14.43.25 · CleanShot Cloud. I didn’t show it in the demo, but it also works when removing / deleting annotations from either side.

(@pete31 thanks again for sharing that original PDF script!)


This looks amazingly useful. When it’s in place, a slightly more detailed guide to where the various scripts need to go/be invoked would be very helpful.


Finally had the chance to think about this again, and so I watched the video just now, and whoa. Incredible stuff. I think this is the ideal for many!

What happens if you add a “comment” to an annotation note without anything highlighted? Just curious.

Looks nice! Are the scripts available for download? :slight_smile:

It has suddenly stopped working and I cannot see what is failing. DT icon bounces periodically, the Smart Rules has the modified files with annotations in its listing, but no annotation is set in my annotations folder. I’ve triple verified that the DT Link is right.

I know the script has a debug option, but I don’t know how to execute it (yes, it is explained in the option itself, but I’m too much dumb (*) to understand it.

Any help is welcomed.

(*) I’m so dumb, that in “Dumb and Dumber” film, I will be “Dumbest”, in relation to macOS scripting.


I told you I’m Dumbest. :sweat_smile:

I had the rule set to bounce DT icon instead of run the script. :rofl: :rofl: :rofl: :rofl: :rofl:

:man_facepalming: :man_facepalming: :man_facepalming: