PDFpen Pro (by Nitro) - Deep linking broken lately

Some month ago I did the shift to the latest PDFpen Pro (which is now sold and maintained by Nitro instead Smile). running v 13.1 on M! latest OS 12.5.1 with latest Hook 3.7.1.(4869) as of today.

problem: PDF deep-linking via links in note-taking apps broken

how to reproduce:

  • when I do all the prescribed as usual: selecting text or TOC in PDFpen (or skim) create the specific Hook, paste it and use it:
  • Result: brings up the pdf at whatever place it was before - but NOT the one in the hook-link
  • Tried: different links to different places; have the app start the pdf anew; trying in lastest Skim vs PDFpen; different note taking apps including TextEdit etc — no avail
BUT to all surprise
  • when when I link thru the hook main menu — it finds the location (previously selected and hooked) right away
  • now, this is of course no work-around or workflow alternative, since
    • I cant’t maintain a list of deep links in the note-taking app (which is what my workflow wants)
    • the main menu hooks seem to maintain only one deep-link at a time, the older gets overridden – besides it would be not useful to clutter the main menu list with e.g. 20 different links to places within one pdf file.
  • and this all worked fine previously

Is this a bug ?

  • would appreciate some suggestion. It really breaks my workflow

may @LucB you could glance at it first since you seem to oversee the core scripts for this?

1 Like

I just tested and found that pasting deep PDF links still works in the software configuration and apps you mentioned . Hook app only supports one hook per PDF. So if you want multiple deep links to a given PDF they need to be pasted inside a document, as opposed to Hook. This hasn’t changed since we introduced deep PDF linking…

First of all thank, Luc for looking into this.

This is what I did. Now and in the past. And calling the deep link from the pasted link within a document, this is what’s broken. While the one supported via Hook main menu is fine.

Thus

  • all my deep-links pasted in documents now are rendered useless and just bring up the App (PdfPen pro or Skim). Neither jumps to the deep-linked place any more. Not from markdown documents nor from out of Notes or TextEdit etc

I am puzzled, since the simple single supported via-hook-mai-menu link works fine. If it were a macOS permission problem, why simultaneously for PDFpen and skim both. And BTW of course checked the Sys Prefs:privacy settings: nothing obvious there too.

Did you test pasted links too?

Yes.

could you please paste the links here, within code blocks so we can see if there’s something wrong with the links?

Here is an example that uses a PDF available here: Claude Lamontagne 1976 - Steps towards a computational theory of visual motion detection: designing a working system Edinburgh claude lamontagne.

  1. I named the document LamontagneC_1976redux PhD thesis.pdf.
  2. I selected text on page “183”, (technically, page 188)
  3. Copy Markdown Link.

That gave me this:

[LamontagneC_1976redux PhD thesis.pdf](hook://file/EXS96tJdR?p=bHVjYi9QREZz&n=LamontagneC%5F1976redux%20PhD%20thesis%2Epdf#p=188&x=0&y=0&s=65&e=196).

You’ll notice #p=188&x=0&y=0&s=65&e=196. They represent the page and on-page location parameters.

PDFpenPro 13.1 and Version 1.6.12 (142).

If I correctly understand, however, these links pasted in documents previously worked for you.

yes, very much so, nicely. For that reason I switched from PDFExpert (which unfortunately doesn’t get its act together while the scripts never worked reliably for me) to PDFpen pro

replicated the same here (same text, same page):


[LamontagneC_1976redux PhD thesis.pdf](hook://file/HR3boRgFP?p=cGRmLzY=&n=LamontagneC%5F1976redux%20PhD%20thesis%2Epdf#p=189&x=57.36&y=362.76)

[LamontagneC_1976redux PhD thesis.pdf](hook://file/HR3boRgFP?p=cGRmLzY=&n=LamontagneC%5F1976redux%20PhD%20thesis%2Epdf#p=189&x=57.36&y=362.76)

PDFpen pro version 13.1 (doesn’t tell me the build in the “About”. Where did you find it? But latest anyway)

So, my link seems malformed, compared to yours?

Using your link no avail either. Your link is supposedly shareable, did I get that right? Or does the share-ability only extend to opening the file altogether, i.e. w/o deep link?

Anyway, still puzzling

Thank you for sharing that.

yes it is, as long as filename is the same. (hook://file/ URLs shared between different users or Macs need to have the same filename at first).

top right corner of its File menu > About window.

it works for me.

I know you said you have latest Hook. But is it possible you have an old version of Hook installed that is being called?

Sorry we could not reproduce the error so we need your help to debug.

If possible, could you please go to Hook Preferences window ->Scripts->PDFpenPro->Open Item, replace the script with the following script and click the save button? Then click one pdf deep link you saved in TextEdit(or other apps). You will see a dialog window, please copy the content and posted here.

After the test is done, please go to Hook Preferences window ->Scripts->PDFpenPro and click on “Reset to Default” button to reset to default script.

Thank you!

Summary
use framework "Foundation"
use scripting additions


on urlDecode(input)
    tell current application's NSString to set urlString to stringWithString_(input)
    set theDecodedURL to urlString's stringByRemovingPercentEncoding -- 4 is NSUTF8StringEncoding
    return theDecodedURL as Unicode text
end urlDecode

display dialog "$0"

set fullURL to "$0"


set AppleScript's text item delimiters to "#"
set urlPath to text item 1 of fullURL
if (count of text items of fullURL) is greater than 1 then
    set fragment to text item 2 of fullURL
    set AppleScript's text item delimiters to "&"
    set kvs to text items of fragment
    repeat with kv in kvs
        set AppleScript's text item delimiters to "="
        set k to text item 1 of kv
        set v to text item 2 of kv
        if k = "p" then
            set p to v as number
        end if
        if k = "x" then
            set xx to v
        end if
        if k = "y" then
            set yy to v
        end if
    end repeat
end if

set fpath to urlDecode(urlPath)
set text item delimiters to "/"
set fn to text item -1 of fpath
set len to length of fpath
set fpath to text 8 through len of fpath
set targetWindow to missing value


tell application id "com.smileonmymac.PDFpenPro"
    activate
    repeat with i from (count of windows) to 1 by -1
        try
            set thisWindow to window i
            set thisDoc to document of thisWindow
            if thisDoc is not missing value and (path of thisDoc) is equal to fpath then
                set targetWindow to thisWindow
                if index of targetWindow is not 1 then
                    set index of targetWindow to 1
                end if
                exit repeat
            end if
        end try
    end repeat
    
    if targetWindow is missing value then
        open fpath
        set targetWindow to first window
    end if
    
    if p is not missing value then
        tell targetWindow
            set doc to its document
            show page p of doc
            if yy is not missing value then
                if xx is missing value then
                    xx = 0
                end if
                tell doc to scroll to X xx Y yy
            end if
        end tell
    end if
end tell

Version 3.7.1 (4869; Integration v. 227)
was the latest as of yesterday

13.1 flat - have you subscribed to some beta build ? Mine seems to be the latest stable version (checked for updates again)

Thus basically we are both using the same Apps and versions

Thank you for reaching out to help.

tried exactly as you wrote, however

  • I have two pdfpenpro entries 1. “PDFpen Pro” and 2. “PDFpen Pro 13”. To be sure I entered your script into both “open item” panes and save.
  • when hitting the deep link within the note-taking file the pdf document comes up as before at just any previous position. No Dialog window opens however. Hook normally does not appear in the task switcher list, but when I search all open windows the only Hook window is the one with the scripts. Is that a permission issue? All my Automation permissions of hook are set as before.

Is the script correct? What App should show with the Dialog Window?

Strange.

Thank you for your help! That’s helpful.

Could you please open Terminal (it is under /Applications/Utilities) and run the following command and post output here:

osascript -e 'id of app "PDFpenPro"'

If your PDFpenPro has different name, please change the name in above command accordingly.

Also, could you please let us know the web page where you download PDFpenPro? Or it is from App Store?

Thank you

  • com.smileonmymac.PDFpenPro

here it is:

Thank you for the info!

I just downloaded a copy of Nitro PDF Pro for individual from https://www.gonitro.com/features and its bundle id is : com.gonitro.NitroPDFPro.retail, which is also supported by Hook. The latest version is 13.3.

They also have business and sign versions. Could you please let us know which one you downloaded? And run the following command to get the its bundle id(change YourPDFProName to your app name).

osascript -e 'id of app "YourPDFProName"'

Also I guess PDFpenPro with bundle id: “com.smileonmymac.PDFpenPro” is not your default pdf viewer. Otherwise, you will see a dialog box when you click on the deep link. Could you please check?

Thank you

this is interesting. Although my “check for updates” never brought more then 13.1 which still had a blue logo and was the first I got within the upgrading process from my original smileonmac license, now thanks to your research I downloaded and installed the 13.3.0 (red logo and called Nitro pdfpenpro) from the site you found.

  • BTW the previous 13.1 was my default pdf reader

Then

Result now
com.gonitro.NitroPDFPro.retail

Then making it the default app and installing your scripts into “open item” (there ist still PDFpenporo and PDFpenpro 13 both - not Nitro pdfpenpro !! ) I created a new deep link and Hook requests permissions granted (same text same page as above by Luc)

[LamontagneC_1976redux PhD thesis.pdf](hook://file/HR3boRgFP?p=cGRmLzY=&n=LamontagneC%5F1976redux%20PhD%20thesis%2Epdf#p=189&x=58.08&y=630.16)

However result is same — still no dialog box, no deep link found, only app opened on arbitrary last page.

Does the hook script have to be adjusted to “Nitro PDFpenPro” ??

Feels we are getting closer, but not there yet

Thank you for the info.

Here is the script to place in Open Item script for com.gonitro.NitroPDFPro.retail. Sorry it is not obvious. You can see the whole bundle id when you put mouse over it. The visible part of the app name is “Nitro PDF Pro re…”. After paste the script, click on the save button. Also after the test is done, do remember click on “Reset to default” button.

Summary
use framework "Foundation"
use scripting additions


on urlDecode(input)
    tell current application's NSString to set urlString to stringWithString_(input)
    set theDecodedURL to urlString's stringByRemovingPercentEncoding -- 4 is NSUTF8StringEncoding
    return theDecodedURL as Unicode text
end urlDecode

display dialog "$0"

set fullURL to "$0"


set AppleScript's text item delimiters to "#"
set urlPath to text item 1 of fullURL
if (count of text items of fullURL) is greater than 1 then
    set fragment to text item 2 of fullURL
    set AppleScript's text item delimiters to "&"
    set kvs to text items of fragment
    repeat with kv in kvs
        set AppleScript's text item delimiters to "="
        set k to text item 1 of kv
        set v to text item 2 of kv
        if k = "p" then
            set p to v as number
        end if
        if k = "x" then
            set xx to v
        end if
        if k = "y" then
            set yy to v
        end if
    end repeat
end if

set fpath to urlDecode(urlPath)
set text item delimiters to "/"
set fn to text item -1 of fpath
set len to length of fpath
set fpath to text 8 through len of fpath
set targetWindow to missing value


tell application id "com.gonitro.NitroPDFPro.retail"
    activate
    repeat with i from (count of windows) to 1 by -1
        try
            set thisWindow to window i
            set thisDoc to document of thisWindow
            if thisDoc is not missing value and (path of thisDoc) is equal to fpath then
                set targetWindow to thisWindow
                if index of targetWindow is not 1 then
                    set index of targetWindow to 1
                end if
                exit repeat
            end if
        end try
    end repeat
    
    if targetWindow is missing value then
        open fpath
        set targetWindow to first window
    end if
    
    if p is not missing value then
        tell targetWindow
            set doc to its document
            show page p of doc
            if yy is not missing value then
                if xx is missing value then
                    xx = 0
                end if
                tell doc to scroll to X xx Y yy
            end if
        end tell
    end if
end tell

Thank you @bchend

One eye-opener after the other. Would never have noticed that nitro-pedfpen meanwhile had its own place in hook and of course not alphabetical any near to the elder sibling PDFpenpro and moreover that there are so many beasts of the same breed depending on the source of download. feels like the full burden of unhealthy variety much like the jungle of Windows versions in the past.

Anyway, did all that, to com.gonitro.NitroPDFPro.retail hook ’open iteim’

  • no avail. still no dialog box either, but as usual: last used page

Learning so much, and yet …

What options left next?

If you paste the deep link in spotlight search and open it, can it open the correct page?

But you can open it from Hook window, right?

Did this problem only happen after you install Hook 3.7.1? Could you please try Hook 3.6.1 and see if it works?

Please remove it after the test is done.

Thank you

I’m also having this problem. Was it fixed by any of the above?

I had a go at some of the above steps, but nothing worked. Deep Linking not working on Nitro PDF Pen (which I downloaded afresh just now, having previously used the Smile branded PDF Pen Pro, which also didn’t work). Some help would be appreciated—I rely heavily on deep linking.

Sorry for the trouble. Could you please send us the following info:
(1)Copy the above command to Terminal, replace “YourPDFProName” with your Nitro PDFPen name and hit the return key. Let us know the result.
(2)Hookmark version
(3)MacOS version
(4)A sample deep link generated by Hookmark

Thank you