Observations about Hook with PDFpenPro

I have been trying for months to get deep linking working with PDFs and have had 0 success. My problems fall into the same categories as yours, to whit the page and x,y coords are getting included in the url but pdfpenpro doesn’t seem to recognize them, and under certain circumstances they are not included in the url. The demo provided by CogSci and pdfpenpro fails 100% of the time on my configuration and no amount of re-install/troubleshooting I have done gets to a solution. I am going to try your solution even though it’s a bit arduous because I really need to link to PDFs with my desired workflow.

For the moderators, FYI Hook does not seem to be configured to have scripts for pdfpenpro despite it being on my machine. For reference I have the latest 13.X version rather than 12.X so possibly that’s part of the problem. I include a screenshot to illustrate the non-presence. If I manually add pdfpenpro (via the + sign at the bottom of the preferences/scripts screen) it still does not load in any scripts and reports that the hook “requires a valid get url script”. It would perhaps be helpful if I could find that script manually somewhere and install it, but the automatic updater does not change anything when it runs.


This is before I manually add pdfpenpro…i reinstalled hook and it doesn’t add it on reinstall.

This is it after I install with + including the error mesage.

Sorry for the trouble.

Could you please run the following command using /Applications/Utilities/Terminal and post the result?
osascript -e ‘id of app “PDFpenPro”’

Also if you uncheck “Only show installed apps” at bottom left of Hook Scripts window, does PDFPenPRO appear?

Thank you!

When I do the osascript I get:

0:1: syntax error: A unknown token can’t go here. (-2740)

When I uncheck the “only installed” box the PDFPen scripts do appear. Here is the open app script:

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

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

This might well work but only if hook knows about it which it probably doesn’t since it’s not showing up as installed. LMK if you have more thoughts. Thanks

I guess the PDFPenPro on your machine has the different bundle id than the one Hook supports.

Sorry about this. I shouldn’t just paste the command on discourse and forgot to double check it.

This is the command that should work.

osascript -e 'id of app "PDFpenPro"'

Or you can right click on your PDFpenPro ->Show Package Contents, open Contents folder, open info.plist file in this folder in a text editor. Search “CFBundleIdentifier”, copy the line after it and post here. Or you can just send us the info.plist file.

Thank you

Same for both: info.plist has:
com.smileonmymac.PDFpenPro13.MacAppStore

osascript -e ‘id of app “PDFpenPro”’ has:
com.smileonmymac.PDFpenPro13.MacAppStore

We just updated the script server with the fix for PDFPenPro MacAppStore version, script version 188.

Could you please go to Hook Preferences window → Update Pane, click on Check now button to update the script?
After the script is updated, please check if there is an entry for PDFPenPRO 13 in Script Pane and there is no “*” at the end of the app name. If there is one, please click on “Reset to Default” button.

Let’s know if the fix works.

Thank you

It absolutely works! Thanks so much for the support!

1 Like