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:

2 Likes

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:

3 Likes

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!)

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).

3 Likes

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.