I customized the default Hook AppleScript in order to get links like the above as following:
tell application id "DNtp"
if exists (content record of window 1) then
-- current open item
if type of (content record of window 1) is PDF document then
set RecordLink to the reference URL of (content record of window 1)
set PDFpage to current page of window 1
set DEVONthinkLink to RecordLink & "?page=" & PDFpage
return DEVONthinkLink
else
return reference URL of (content record of window 1)
end if
end if
if class of window 1 is in {viewer window, search window} then
set selected_items to selection of window 1
if (count of selected_items) = 1 then
if type of item 1 in selected_items is PDF document then
-- current selected item
set RecordLink to the reference URL of item 1 in selected_items
set PDFpage to current page of viewer window 1
set DEVONthinkLink to RecordLink & "?page=" & PDFpage
return DEVONthinkLink
else
return reference URL of item 1 in selected_items
end if
end if
end if
-- selected group
return reference URL of root of window 1
end tell
If I execute the script from the Script Editor it works fine. But when I activate the Copy Link command from Hook I get a URL without the “?page=0” part.
Thanks – I can see using this on a page of a lengthy PDF to use Hook to link an extensive note to that page. Cool idea, I urge CogSci to incorporate your idea into the baseline set of scripts (@LucB)
Having specific hooks to specific pages of a long PDF would be particularly great in the enterprise and for attorneys and litigators. Courts gets hyperlinked courtesy copies of briefs and documents. That way the court can click on a cite and go directly to a page of an exhibits. When you put one Hook to a pdf it goes to the page where you put the hook. But if you put another hook on the same PDF both Hooks go to the last hook page for the you made. If Hook can fix it so you can put many hooks to the same PDF it would be a game changer.
you’ll very soon be able to Copy Link to get to the specific page. That hook would need to be pasted in an associated documented however, as Hook only presents one link per target resource in the Hook window (with the exception being Pinned – i.e., a pinned bookmark can repeat something that is also contextually hooked).
Sorry!!! I seem to have mixed topics (hence my mentioning PDFpenPro) [i switched too fast between customer support; other Hook tasks; and academic work.] Hook currently only supports deep links to PDFpenPro and Skim. PDFoo supports deep linking, but you’d need to use its Copy Link function. Not as robust or convenient as Hook’s deep links. If they add an API for deep linking we would likely support it. Deep-linking aside, PDFoo works fine with Hook. There’s also an alternative Hook script for Curio. In Hook 2.3, Adobe Reader DC and Adobe Acrobat will get deep PDF linking too.
Now that we have the infrastructure in place, we’ll look at deep PDF linking for DEVONthink.
Please keep in mind that Hook’s deep PDF linking main use cases revolve around Copy Link and Copy Markdown Link , rather than hooking (bidirectionally linking). Hook will currently only show you one HOOKED entry per destination document. However, for each deep Copy Link or Copy Markdown Link, Hook will add a bookmark. You can find each bookmark with Hook’s search tool. Hook’s bookmarks may be renamed, for ease of processing.
We’re quite committed to deep PDF linking to support researchers, lawyers and all other deep PDF users. We also value DEVONthink integration.
Yes, this is on our list. We’re interleaving integrations with new software (3.4.2, 3.5 public beta, and an update to our iOS beta are all nearly ready).