# Sending annotation to DTTG

**URL:** <https://discourse.devontechnologies.com/t/sending-annotation-to-dttg/20976>\
**Category:** Tips\
**Created:** [October 7, 2016, 7:37pm UTC](https://discourse.devontechnologies.com/t/sending-annotation-to-dttg/20976 "2016-10-07T19:37:15Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![kseggleton](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/kseggleton/32/5455_2.png) [@kseggleton](https://discourse.devontechnologies.com/u/kseggleton)\
**Post date:** [October 7, 2016, 7:37pm UTC](https://discourse.devontechnologies.com/t/sending-annotation-to-dttg/20976/1 "2016-10-07T19:37:15Z")

</div>

I really like reading about other peoples workflows and am interested to know how other people are automating DTTG. One of the things I like about the desktop version of DT is the ability to use third party apps or scripts to extract annotations from pdfs in DT. On iOS it is a little more difficult but not impossible. I thought that I would share how I extract annotations from pdfs and send the annotations as markdown formatted text back to DTTG. While the annotation tools in DTTG are nice LiquidText gives the ability to extract annotations and save them as a docx file or to the clipboard. I do the later.

First I copy a pdf to LiquidText from DTTG, then I markup the pdf using LiquidText’s annotation tools, then I export the notes outline via the share sheet to the clipboard. Finally I fire up the following python script in Pythonista (launched via a Launch Center Pro widget in Notification center).

```auto
#Script to take contents of clipboard, derived from LiquidText, strip out unnecessary words, format for Markdown and send to DevonThink

import re
import clipboard
import urllib.parse
import webbrowser

clip = clipboard.get()

#Replaces carriage returns with new line
stripReturn = re.sub("\r","\n", clip)

#Search for title and remove unnecessary words
searchTitle = re.match('Notes\sin\s(.*)\.pdf',stripReturn)
title = searchTitle.group(1)
cleanTitle = re.sub('(\‘)|(\.pdf)','',title)

#Remove first two lines
stripTitle = re.sub('Notes\sin.*\n',"", stripReturn)

#Remove unnecessary words and format in Markdown
stripObjectGroup = re.sub("Object\sGroup","", stripTitle)
stripExcerpt = re.sub("Excerpt:\t","> ",stripObjectGroup)
stripComment = re.sub("Comment:\s\s","", stripExcerpt)

#Add back title
text = '# Notes from ' + cleanTitle + stripComment

#URL encode
encodeText = urllib.parse.quote(text)
encodeTitle = urllib.parse.quote(cleanTitle)

#Send to DevonThink
devonURl = 'x-devonthink://createText?title=' + encodeTitle + '&location=&text=' + encodeText

webbrowser.open(devonURl)

```

The LCP url scheme for launching a Pythonista script is in the form of pythonista3://{{name\_of\_script}}?action=run

The same thing can be achieved with the Workflow app and Drafts. What would be great is if the url scheme for DTTG expanded so that more iOS automation could be achieved.

---

_[View the full topic](https://discourse.devontechnologies.com/t/sending-annotation-to-dttg/20976)._
