Stream annotations from your PDF reading sessions with DEVONthink

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:


… But the annotation MD file does not contains any annotation, only the header… :sweat:

Hmm. Did it work previously? I was using it a few days ago but can’t recall what version of DEVONthink I was on.

Yes, it was working flawlessly. What I’ve done is re-download both script and smart rule and install as new, deleting previous one, without luck.

And finally I understood the “debug” way and yes, it generates a new MD file… with the header only and no annotations. I’m using last DT version, 3.8.6, and it worked with same version before.

2 posts were split to a new topic: R Murphy - Stream Annotations

This is amazing and is working for me. It is storing the annotations in my inbox. I have setup a rule to move them to a group as instructed above.

But, the criticmarkup’s highlights are not getting removed for me.

Thank you. This is probably one important feature that is missing in Devonthink. I was really needing it and it works!

It is still not working in 3.8.7 version: it creates or updates the MD file, shows the a number of annotations, but MD file is empty. See captures.

Is this working for all of you?

Sorry for the delayed reply. Indeed, it’s still chugging along for me! You might want to try the following debugging process:

  1. Open the script, switch the debug flag to true, and save it. (For efficiency, you may also want to switch the value of delayAfterReadingSessionInMinutes to a lower number so that the script triggers faster.
  2. Copy and paste the modified script into the smart rule. (Remember that inline scripts work better than script files for this.)
  3. Quit and relaunch DEVONthink.
  4. Annotate a file and wait for the trigger to fire.

The debug flag will report what’s happening as the script progresses to give you a sense of where it might be getting stuck. To shut debugging off, switch the properties back in the inline editor and then quit and relaunch DEVONthink.

I have the same md files. It works before I update to current version few weeks ago.