Can I link to annotation WITHIN a PDF?

When I highlight text in a document, I need to be able to extract the text and link to the exact location I copied it from. Is this possible with DevonThink?

No, you cannot link from a note created in a PDF. PDF notes are plain text. Further, they are not searchable in DEVONthink.

This can be done if you create a rich text note in which to hold the extracted text. You can link to the page in the PDF to which your extract or comment refers.

Choose View > PDF Display > Sidebar. Page icons will be displayed to the right of the pane that displays the PDF. Control-click on the appropriate page icon and choose Copy Page Link. Then paste the Page Link into your rich text note.

The Annotation template (Data > New from Template > Annotation) is a convenient way to create such a note (a keyboard shortcut is provided). The Annotation note is linked both to and from the PDF being annotated.

Annotation notes can be used with documents of any filetype, not just PDFs.

Reposting this script because it might help other readers.

20110309.1 v1
20131120.2 v2 simplification and enhancement
Use with a PDF or RTF open in a DEVONthink window, select some text that you want to link to and run this script.
The link to that text in that document is on your clipboard.  If the document is a PDF, the link includes a page link.

-- 20131121 == there is a problem that stacking ?page and ?search options results in no highlighted selection on link-back

-- search strings are limited to the value of the MaxLen property; characters including blanks
set MaxLen to 500

tell application id "com.devon-technologies.thinkpro2"
		set theSelection to the first item of (the selection as list)
		if theSelection is {} then error "Select an item, please"
		if the kind of theSelection is not in {"PDF", "PDF+Text", "RTF", "RTFD"} then error "Source should be a PDF or RTF"
		set theString to selected text of think window 1
		if theString is "" then error "Select some text, please"
		if length of theString is greater than MaxLen then error "That selection is longer than " & MaxLen
		set theStringEncoded to (do shell script "php -r 'echo trim(urlencode(" & "\"" & theString & "" & "\"));'" as string)
		set docName to the name of theSelection
		if the current page of think window 1 ≠ -1 then
			-- the document is a PDF
			set thePage to the (current page of think window 1) as string
			set pageURL to the reference URL of theSelection & "?page=" & thePage & "&?search=" & theStringEncoded
			set o_HTML to quoted form of ("<font face=\"helvetica\">" & theString & " (See " & docName & ": " & "<a href=\"" & pageURL & "\"> page " & thePage & "</a>" & ")" & "</font>")
			-- the document is not a PDF
			set pageURL to the reference URL of theSelection & "?search=" & theStringEncoded
			set o_HTML to quoted form of ("<font face=\"helvetica\">" & theString & " (See " & "<a href=\"" & pageURL & "\">" & docName & "</a>" & ")" & "</font>")
		end if
		do shell script "echo " & o_HTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

Thanks for the script, korm, but sadly, this is only a partial solution. If I had to select every highlight I make and run the command each time, it would seriously hinder my workflow.

Too bad there is no built-in functionality for this.

Assign the script to a keyboard shortcut. I’m not seeing more work with “highlight text + click command” than anything else? If you want a report of all your highlights, page number, etc., then use Skim or Acrobat – though you will not get link-back hyperlinks with those or with anything else. That’s why I wrote the script to overcoming the shortcoming. But, if it’s useless then it’s useless.

Sure, Skim, Sente and Papers can all export annotations, but no software adds pointers to the annotations themselves. They will at most link to the file… :frowning:

One of the reasons I use DEVONthink’s Annotation template to annotate documents is that it allows me to insert Page Links or searchable cue strings to the various locations in the referenced document that I want to quote, summarize or criticize. :slight_smile:

If I extract a quote from a PDF and paste it into its Annotation note, I can also paste the Page Link of the page in which the excerpt is located. Click on the page link and the PDF opens at that page.

Alternatively (works in a number of document filetypes) I can designate a fairly unique text string as a marker of a location in that document, and paste the cue string into my note. To return to that location in the referenced document, copy the cue string (enclosed within quotation marks) into a DEVONthink search query and perform the search. The referenced document will be listed in the results. Select it, and it will scroll to the first appearance of the cue string. Usually I pick a 5 or 6 word text string, with the result that the referenced document is the only result of the search (in a database holding tens of thousands of documents), and the scrolling position when that document is selected is the desired location.

An attorney has described how he uses an Annotation note linked to a video document of a deposition. As he’s watching the video, he can make notes about the facts alleged by the deposed person. He can include the video timeline at which a statement is made, so that it’s easy to return to it.

Workflows using the Annotation template allow one to make notes about documents of any filetype. The notes are searchable. The source and location in the referenced document are self-documenting. Images such as graphics or photos can be included. Multiple topics can be included (I often use little Cornell Notes tables to separate topics within an Annotation note). The very existence of an Annotation note is evident when one opens any document in a database, as the navigation bar immediately above the pane in which the document content is displayed will display a clickable link to that document’s Annotation note, if one exists.

Want to see all the notes one has made about a document? They are in its Annotation note, which is searchable. And as links are easy to include, one could create a link to other documents related to a topic, so the approach is highly extensible. The Annotation note can easily be ‘printed’ as PDF if one wishes to send it to a colleague.

The initial reaction of many users to the Annotation note system is that it appears clumsy, as it involves the creation of a second file. My opinion is that it offers a very rich, extensible and adaptive approach to annotation, and so it’s the most efficient tool for making notes about references when I’m working on a project.


Thanks for your suggestion. My question is “Do you have to copy a highlight and insert a link for each quote?” In other words, using the Annotation file, do you have to copy/paste passages into it or can it be done automatically?

achili, I manually copy/paste the Page Link, and also any excerpt to be copied.

This may take me a few seconds. At least in my case, automation of that procedure would save me no time or effort. That’s because most of the time I’m spending is required to evaluate the information I’m reading and to create a summary of it in my own words, while considering how I’m going to use the information. Sometimes that requires a few minutes of staring blankly into the distance while I’m thinking and composing my note; during that interval I’ve done the manual copy/paste of the Page Link. :slight_smile:

My freshman year in college coincided with the construction of the first real multipurpose computer. As it was then the only one in the world, I didn’t have access to it. The information I worked with was on paper: text books, course handouts and my notes taken during lectures. My initial approach in studying these materials was to highlight or underline them. I made A’s. But one of my professors was amused to see that some of my textbooks were almost completely underlined. He suggested an alternative approach which is that of Cornell Notes (Google it), to improve comprehension and retention of information. I switched to that instead of marking up my reference materials. Still made A’s, but understood the concepts much better, and my reference materials no longer were disfigured. I’ve carried over that approach into use of my computer databases. I don’t highlight or otherwise mark up my documents, but create notes (using the Annotation template) that hold my summaries and comments about them, and that often include topical notes in the Cornell Notes format. That works well for me.

Other users prefer highlighting terms or passages, especially in PDFs. The scripting section on our user forum holds threads about scripts that can automatically collect those highlights from a PDF annotated in that way. I suppose it would be possible to also capture the associated Page Links.


Extremely interesting reading… Thanks.
It took me the larger part of the afternoon to digest what you write and to grasp the full meaning… I didn’t make a Cornell Note out of it (yet). Interested in that methodology as well.

I own DT To Go but have never really used it. (1.5.8)
Do you consider your workflow as described above doable on the iPad?

Not with version 1.x of DEVONthink To Go. The second generation (free to registered users of the first generation, when released) is now in beta testing, and will be much more useful.

However, iOS and iOS devices are still limited compared to OS X and current Macs. iOS doesn’t support AppleScript, for example. I’ll continue to do most of my work on Mac.