Combine "take rich note" and "copy page link" = bookmark

I index my digital editions of various magazines and journals, all in pdf format. It would be useful to have one command or script to copy highlighted material (Take Rich Note) and insert the page link within the text document.

I generate a “bookmark” to specific pages in the document with the following:

  1. “Copy the Page Link” to the clipboard,
  2. Highlight text, use Services to “Take Rich Note”, capturing the text as a title which brings up the distribution menu to assign the note to a folder
  3. Assign the note to a folder (typically an Inbox, for easy retrieval)
  4. Retrieve the note and insert the the page link from the Clipboard
  5. Move the note to the appropriate folder

If the page link were inserted in the note, I could assign the note directly to the appropriate folder.

Are you aware that devonthink captures the URL for you when you capture as RTF? It shows up in the navigation bar when you view the document.

Yes, however that is not the issue here. I am setting a bookmark for text already indexed within DT. The text I capture defines the subject matter and the link is the page link within the document assigned by DT.

I use the link from Copy Page Link in OmniOutliner to reference the original article. With the Rich Note and Link combination, I can place a bookmark in any folder within DT.

I’m not entirely clear on your requirements, but try this:


-- Experimental
-- 20101019 Use at your own risk.  Loss of data is your risk.
-- Select some text in a document in DTPO
-- Script creates a bookmark (inetloc) to that page of that document
-- Does not open the document with the text highlighted
-- When clicked in DT, opens the document in a new window (open in tabs seems not work)


tell application id "com.devon-technologies.thinkpro2"
	
	set theSelection to selection
	if theSelection is {} then
		error "Please Select Something"
	end if
	repeat with thisItem in theSelection
		set theTitle to selected text of think window 1
		if theTitle is {} then
			error "Select some text"
		end if
		
		if the current page of think window 1 ≠ -1 then
			set thePage to "?page=" & ((the current page of think window 1) as string)
		end if
		
		set theUrl to "x-devonthink-item://" & (uuid of thisItem) & thePage
		create record with {type:bookmark, name:theTitle, URL:theUrl} in incoming group
	end repeat
end tell

This works well for PDFs. Might work for other doc types, but I haven’t tested that. The link works in OO3 Pro. When the link is clicked in DTPO it must be double-clicked and opens in a new window. I believe that problem relates to DT’s custom URLs and has been discussed elsewhere in the forums.

I’ve never created/compiled a script before.

However, between the DT help file. and the Applescript Editor, and some “stumbling around”, I created the script, inserted it into the Script folder (and of course the script menu) and … IT WORKS! It took me a while to realize that the bookmark appears in the Global InBox rather than the inbox of the sub-base but that is obviously the appropriate place for the bookmark to appear.

A double click does indeed get me to the correct article/page. This is exactly what I wanted. The corresponding DT URL appears in the Info window, which I can then transfer to OmniOutliner to document the citation.

Thank you for the script and for introducing me to more of the versatility of DTPro.

No need to cut and paste the URL. The bookmark itself can be dragged into an OO3 document. Here’s a bookmark created by the script, and the same bookmark dragged into OO3 Pro. Hover over it in OO3 and an arrow appears to the right that can be clicked to open the document and page in DT.

Thank you for pointing out that the “bookmark” can be dragged into OO3. However, when I try to open the link in OO3, I get the following message:
Unable to open attachment “The document containing the attachment needs to be saved before you can open the attachment”.

I tried moving the bookmark out of the Global Inbox to an appropriate folder but I still get the same error message.

There is something else going on with your configuration. I just tried the above by dragging the bookmark to a blank, unsaved OO3 document and I do not see the error here. One factor that you can eliminate is the location of the bookmark. Once it has been copied to another document (OO3, text document, etc.) it can be deleted. Clicking on the bookmark in the OO3 document just opens the link URL, not the original bookmark document.

That error message is generated by OO3 and means that you haven’t saved your OO3 document. “The document containing the attachment” refers to the OO3 document, not the DT document.

I’se solved the dilemma …very subtle; a novice’s error.

All is well when I first select (click) the link and then drag the link by placing the cursor on the blue underlined text of the link and dragging.

The problem arose when I dragged the link by placing the cursor on the icon next to the link without selecting the link, merely dragging the item from the index list. It appeared to give the same visual result in OO3, but produced the error message.

The bookmark transfers successfully and opens DT without the need to save the OO3 document.

hi @retac, are you still using this approach? i think this is something I would care to do as well. But am no Applescript expert. Got to learn it!

Thanks!

If you are using something as powerful as Omnioutliner then there are better approaches than creating separate bookmarks for each reference:

QuoteHighlight&Annotate script

Cite&Write with OmniOutliner

Frederiko