PDFpen Pro (by Nitro) - Deep linking broken lately

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

could you please run this from Terminal and let us know the result:

osascript -e 'id of app "<YourPDFProName>'"

please replace "<YourPDFProName>" with the name.

( Do you have multiple versions of Nitro?)

also could you please try this:

paste the markdown link here, wrapped in code , using the formatting toolbar button above: </>

Thanks.

Thanks for the replies. I have PDFpenPro2 and Nitro PDF Pro installed, but I am currently using the latter. I tried the command in terminal but nothing happened with osascript -e 'id of app "NitroPDFPro” - not sure what I am doing wrong there.

I downloaded the Lamontagne document and selected text on p.183 (p.188) of the pdf, which gave me this as a markdown link: [LamontagneC_1976redux.pdf](hook://file/KQSYuz5Dr?p=Y2hyaXN0b3BoZXJsYW5nbGV5L0Rvd25sb2Fkcw==&n=LamontagneC%5F1976redux%2Epdf#p=188&x=61.44&y=692.69)

I have Mac OSX Ventura 13.0 and Hookmark 4.0

Sorry to bump, but still looking for a fix. Thanks.

Sorry, please try this ( replace with your Nitro PDF Name):

osascript -e 'id of app "You Nitro PDF Name"'

Thanks. I receive this response:

com.gonitro.NitroPDFPro.retail

Sorry I have tried different ways to reproduce the problem but still no luck. Is it possible that you create a short video for this issue, which might give us some hint?