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

**URL:** <https://discourse.devontechnologies.com/t/script-display-deep-linked-pdf-page-number-in-hook-link-title/71524>\
**Category:** DEVONthink\
**Created:** [June 18, 2022, 5:41pm UTC](https://discourse.devontechnologies.com/t/script-display-deep-linked-pdf-page-number-in-hook-link-title/71524 "2022-06-18T17:41:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AW2307](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/a/8c91f0/32.png) [@AW2307](https://discourse.devontechnologies.com/u/AW2307)\
**Post date:** [June 18, 2022, 5:41pm UTC](https://discourse.devontechnologies.com/t/script-display-deep-linked-pdf-page-number-in-hook-link-title/71524/1 "2022-06-18T17:41:44Z")

</div>

Hi,

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](https://discourse.devontechnologies.com/t/deep-linking-hook/69403/5). 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.

 ![CleanShot 2022-06-18 at 19.34.41@2x](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/e/b/eb88c12165c4f2412e9bfb688b08a25581e193cb.png)

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

```auto
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:

 ![Hook Page Link](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/5/3/53b805aed9c5e78169e5ec836572d6f578f2c6ea.png)

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

 ![CleanShot 2022-06-18 at 19.39.30@2x](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/b/c/bc5bf1ee9e02bc17b38e82bda8dc055b01b86ebc.png)

---

<div class="post-metadata">

**Author:** ![cgrunenberg](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/cgrunenberg/32/7172_2.png) [@cgrunenberg](https://discourse.devontechnologies.com/u/cgrunenberg)\
**Post date:** [June 20, 2022, 8:00am UTC](https://discourse.devontechnologies.com/t/script-display-deep-linked-pdf-page-number-in-hook-link-title/71524/2 "2022-06-20T08:00:18Z")

</div>

Thanks for sharing these scripts!

---

<div class="post-metadata">

**Author:** ![system](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/2X/4/4e6ff70c96be2eb307a274d890bba8d71ba671b3.png) [@system](https://discourse.devontechnologies.com/u/system)\
**Post date:** [June 19, 2025, 8:01am UTC](https://discourse.devontechnologies.com/t/script-display-deep-linked-pdf-page-number-in-hook-link-title/71524/3 "2025-06-19T08:01:03Z")

</div>

This topic was automatically closed 1095 days after the last reply. New replies are no longer allowed.
