Observations about Hook with PDFpenPro

Luc,

First of all, Happy New Year and thank you for such a rapid response on a Weekend day from the West Coast (I live in Kitchener-Waterloo, ON).

The Hook Link only takes me to :
a) The Filename of the PDF in the Finder.

This occurs whether I paste the Link (derived from a Command Shift Space or using the Contextual Menu Bar approach) in

a) a To-Do App,
b) TextEdit,
c) or leave it in Hook’s Bookmarks.

The File itself does not open with an activation of the link nor does the PDF inside PDFPenPro12 scroll to the Deeplink site EVEN if the file is already open inside PDFPenPro12 and the application is running / at the forefront with no other apps running.

As a Medical Doctor, it would be super useful for me to create a Database of Hyperlinks to existing PDFs of Medical Articles, Billing Code Books, Chapters/Sections of Current Reading Materials, etc.

It is unimportant how the UI inside Hook is accessed as long as the actual link to the PDF is to a specific location.
Bidirectionality of the link is also unimportant in many of these cases.

This would be my case-use for Hook that currently is only available in a limited way inside applications like EverNote, DevonThinkPro, Curio, and perhaps TinderBox.

Respectfully,
Pankaj Chand

That is precisely my use case as well - and it works extremely well for that purpose.

Are you actually highlighting some words when you create the link? That is necessary- you cannot simply put the cursor somewhere in the PDF but rather you have to highlight some text before you create the link.

Hi Richard,

I tried it again after your email and the result is still the same.
I was aware that I needed to highlight a piece of text (works similarly in Gmail as well as many other linking applications). Clicking on the Link where I paste it only highlights the filename in the Finder directory where the file is located without opening the file, scrolling to the section.

Do you think it may have something to do with other Applications running in the background preventing Hook or PDFPenPro12 from receiving the Invocation?

I am jealous that you have this working as it would be a huge boon for me to deconstruct sections of Kindle books, other PDFs, and make my own X-linked database from Pictorial Links (MindMapping) like the hyperlinkable body parts on this website: https://www.wheelessonline.com/

I am hoping to create my own Information Infographic Mindmap on my own Domain with Crosslinks to everything using Cloud URLs, local filelinks with Hook, EverNote and DevonThinkPro links, etc.

Pankaj

I should mention, I am still running Mojave 10.14.6 and older versions of EverNote 7.14 as I found updating many of these problematic as my ScanSnap software wasn’t updated with Catalina and therefore the perpetual nuisance of working things breaking down meant I spent more time fixing my broken computer software links than actually being productive.

Pankaj

It’s been tested on that OS too… could you please copy/paste here (Or send via PM) a specific URL that is supposed to be deep but isn’t working, as well as the name of the file you are linking to, and the page number linked to?

How do you have the middle preference set in Hook?

image

BTW - once you get this working (and I am sure you will) you might want to try something similar to this which I set up this week - do you use Keyboard Maestro?

1 Like

THANK YOU Richard and Luc. Problem SOLVED. I had the middle checkbox still checked (I guess it is the default setting and I did not change it as prior to now, the game-changing feature of locating a point inside a PDF did not exist until recently with Hook 2.2 and above).

You are both SuperStars!

I do have Keyboard Maestro but not particularly versed in its’ use / syntax and have even less knowledge of writing in AppleScript, Automator, etc.
I consequently have used Hazel, Super Shortcuts and the like in lieu of trying to learn programming.

Just last week, I started using Keyboard Maestro version 9.1 to create the following Indexing Strtaegy for all my PDFs inside EverNote which allows me to create both Local and Shareable WebLinks to PDFs parked inside a Desktop Copy of EverNote. I am trying to use the Index it creates to be able to use either MacOS or iOS to retrieve any PDF even if the Folder location moves inside EverNote:

Here is a screenshot. I would welcome ideas on writing better Scripts.
image.png

I also use Typinator, TypeIt4Me, and Textexpander but am strill struggling with making it all work in a simplified way. Maybe I have too many tools and ADHD!
I also have LiquidText and MarginNote 3 but have not learned how to use them yet.

feel free to explore these tools as they are all assistive Brain technologies for my aging brain.

Respectfully,
Pankaj

2 Likes

My suggestion would be to fully replace Evernote with DT3 and Tinderbox :slight_smile:

That of course is quite a topic for discussion by itself

Right. The clue, I think, is the Hook URI ends with “page=nnn” if it’s a reference to a spot in the PDF. (At least that’s what my experimenting got me last week.)

(I also think the URI contains coordinates on the page - but I’m less worried about that.)

Yes, the coordinates are page number and on page. We’ll add info about that in customer documentation.

Our URL format is meant to allow users to switch from one PDF app to another (that supports deep linking in this manner), like what we do for email, as these coordinates are per the PDF spec (as email IDs are from RFC5322).

1 Like

Thanks for confirming this.

I acknowledge knowing when to surface an API is tricky: If you think it might change you should be wary. On the other hand if it’s stable encouraging people to rely on it is helpful in creating ecosystem.

It’s good that the intent is to help multiple PDF handling programs - by publishing the API. (The one I’m working on - automatically generating links to pages based on searches for specific text at a specific font size - isn’t and won’t be commercial but I’ll tag along for the ride.) :slight_smile:

I also like that the API is general enough to permit all sorts of integrations.

Hi everyone,

I’ve got a problem with deep linking from PDFpenPro (and Skim, as well).
If I set up a deep link from PDFpenPro, the link is made correctly, i.e. it directs to a page and coordinates. If I open this link via Skim, it jumps to the right position.
But if I try to open the link by PDFpenPro, it always jumps to the start of the right page, (but) not to the right coordinates.

In addition: If I set up the link from Skim, the coordinates are missing, so all PDF programs can only jump to the start of the right page.

see example below

“[annurev-2Epolisci-2E10-2E072805-2E103054.pdf] (hook://file/ycE4BRMLd?p=RnVIL1Nob3J0IFJlcG9ydA==&n=annurev-2Epolisci-2E10-2E072805-2E103054.pdf#p=3&x=0&y=0&s=1082&e=1091)”

(split the link, so you can see it)

As a work around, I set Skim as my main PDF reader and manually invoke PDFpenPro to make deep links, but that’s a little bit cumbersome, since I have always to remember to choose “open with” and I would prefer to use only one PDF app (ok, in reality I’m using preview and pdf expert as well…) at the same time.

Do you have any ideas, what causes this unexpected behaviour?
Many thanks in advance!

Mac OS 10.14.6, Hook 3.1, PDFpenPro 12.2.2, Skim 1.6.3. (133)

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