useful keyboard shortcut for making RTF notes about PDFs

It’s not possible to find “exact location”, but it is possible to find strings. IOW, if I have a PDF with a text string “Situational rather than abstract” then this link will open that PDF and find that string:

x-devonthink-item://9FF05E3E-C0F9-4890-B74F-F7373AF372CF?search=Situational+rather+than+abstract

Here’s the script that creates the link. Obviously, the link will find the first instance of the string. Use your keyboard to find more instances. The link created here is a plain text link (not a pretty RTF link). This is an old script of mine, and someday if I have time I’ll pretty it up to make RTF links. Finally, the best use of this is not so much to search for strings you want to annotate, but to use the link to find unique “anchor” text near to where you want to open the PDF. For example, this search string is just a snippet of text, but it’s close to where I want to jump in the PDF.

x-devonthink-item://076CFE87-DC5B-4915-B6AA-534E2D3378A7?search=+J.+Ong.+Orali

Here’s the script:

set MaxLen to 1000

tell application id "com.devon-technologies.thinkpro2"
	set theSelection to selection
	if theSelection is {} then error "Select an item, please"
	repeat with thisItem in theSelection
		set theCitation to selected text of think window 1
		if theCitation is "" then error "Select some text, please"
		if length of theCitation is greater than MaxLen then error "That selection is longer than " & MaxLen
		set theCitationEncoded to (do shell script "php -r 'echo trim(urlencode(" & "\"" & theCitation & "" & "\"));'" as string)
		set the clipboard to the reference URL of thisItem & "?search=" & theCitationEncoded
	end repeat
end tell

-- example
-- x-devonthink-item://B03F511C-E9EA-4228-A4B3-DB047E269CD8?search=%E2%80%9CGoldie.%E2%80%9D+The+other+fish+you+name+%E2%80%9CGreenie.