Script: Display deep linked PDF page number in Hook link title


I’ve been experimenting with Hook and came up with a script for enhancing deep links to PDF pages in DevonThink @LucB

@cgrunenberg already offered a script for deep linking to PDF pages in this post. By adding this as a custom integration script in the “Get Address” section in the Hook scripting settings, the link leads to the selected PDF page.

However, while the link is now a deep link, the page number doesn’t yet show in the link title.

To enable this, a modified “Get Name” script is needed:

tell application id "DNtp"
	set theWindow to think window 1
	if exists content record of theWindow then
	set theName to name of content record
	set theTime to current time of theWindow
	set thePage to current page of theWindow
		if thePage is not -1 then
		set theName to "[Page " & (thePage as string) & "] " & name of content record 
		else if theTime is greater than 0.0 then
		set theName to "[" & (theTime as string) & "] " & name of content record 
		end if
		return theName
	end if

    if class of window 1 is equal to viewer window then
        set selected_items to selection of window 1
        if (count of selected_items) = 1 then
            -- current selected item
            return name of item 1 in selected_items
        end if
    end if
    -- selected group
    return name of root of window 1
end tell

This is what the result looks like when adding the same link after the modification:

Both scripts need to be added under the Hook settings > Scripts


Thanks for sharing these scripts!