PDF Expert integration scripts

I’ve seen some interest in PDF Expert integration. Here’s my script to integrate — ideally PDF Expert would add AppleScript support.

I don’t use PDF Expert myself and haven’t done much testing, so do let me know if this does what you want.

Get Name

tell application "System Events"
	get name of first window of process "PDF Expert"
end tell

Get Address

tell application "System Events"
	tell process "PDF Expert"
		if enabled of menu item "Show in Finder" of menu 1 of menu bar item "File" of menu bar 1 then
			click menu item "Show in Finder" of menu 1 of menu bar item "File" of menu bar 1
			delay 0.1
			tell application "Finder"
				set theItems to selection
				set ext to name extension of item 1 of theItems
				if ext = "hook" or ext = "HOOK" then
					set filepath to item 1 of theItems as alias
					return read POSIX path of filepath
				end if
				set theURL to URL of item 1 of theItems
				close front window
				activate application "PDF Expert"
				get theURL
			end tell
		end if
	end tell
end tell

This is awesome- works great- thanks so much!

1 Like

Just tried this, works perfectly and so easy to implement. Really enjoying Hook and exploring the ways in which it can enhance my work.


Hi guys. Complete newbie here. I had a quick read of the Integrations instructions but I’m clearly missing a key point. I’m unsure as to where / how you are supposed to actually save these script files to invoke them in Hook. This PDF Expert one is bang on for what I need so thanks @stevelw for creating this.

Would you have the patience in explaining how / where I have to save the script(s)? Thanks in advance for your help.

The instructions for editing Hook scripts are here. Let me know if you’re still lost.

1 Like

No. I figured it out. Thanks Steve. Works great. Much appreciated.


I am trying to use PDF Expert with Hook and used the script suggested by stevelw to do so. The script works in a fashion, but it only links files to PDF Expert the application, not to any target file within PDF Expert. So, if I try to link a Word file to a PDF Expert file, all I get is a link to whatever file happens to be currently open in PDF Expert. Thus, if I create a link to a file open in PDF Expert but then close that file and open another file, the latter is what my Word file will then be linked to. I am hoping the script can be modified to accomplish what I want, but I don’t know how to do it.

I must have made some error when I originally entered the script, because now the script suggested by stevelw links, as intended, to individual PDF Expert files.


Are the PDF Expert scripts still working with PDFE 2.5.3 and Mojave? I believe that I have installed them correctly, but I am still getting “No linkable item found” when I invoke Hook.

as part of the Get Address script, @stevelw wrote:

If you were to try increasing this number, the result might be better. Hook > Preferences > Scripts .

PDF Expert currently lacks AppleScript. (I was in touch with them again this week. Hopefully we will see some progress there.)

Thanks Luc. Tried increasing delay to 0.5 with no effect. BUT, I have discovered some strange behaviour that may have a bearing.

I use Path Finder (7) instead of Finder. I have tried applying both the script above and the one in the PDF Expert & Notability thread in the Get Address window. Currently I am using the one on this page, unchanged except for “delay 0.5”.

When I open a document in PDF Expert and invoke Hook, focus switches to Path Finder and the file for the document I am looking at is revealed in its PF window. It is as if I had cut straight to “Show in [Path] Finder”.

Curiously, if I change “Finder” in the script to “Path Finder”, focus stays with PDFE on invoking Hook, and just a blank Hook window opens (no linkable items). Then if I replace the Get Address script with the version in the Notability thread, the effect of invoking Hook is to close all open Path Finder windows! Clearly these scripts are not working as intended on my system, but this is probably due to the interaction with Path Finder. (I am also using dual monitors, but I don’t believe this is affecting things.)

@NickSloan I’m using Path Finder (9.2) and the original script from @stevelw works well for me after changing “Finder” to “Path Finder”. However, there’s one “gotcha”: I need to click on the page area of the PDF before invoking Hook. If I don’t do that, I get a blank Hook window, as you found.

I’m still trying to find out exactly which conditions cause the script to fail. If I use a keyboard command to move to a new tab in PDF Expert, or activate PDF Expert via LaunchBar, it seems to fail. But if I first click on the page I want to link to, AFAIK it always works.

GUI scripting is a pain. If there’s any combination of keystrokes that would move the focus to the page area of the current PDF, maybe we could add that to the script.

welcome to the Hook Productivity Forum, @chazzo

Agreed. Still, we’ll have another look at that UI scripting, but we can’t commit to this working.

We haven’t had a specific commitment yet from Readdle that they will provide the bit of automation required for linking. They would need to be the ones to speak to their automation plans if any, of course. Fingers crossed.

As it stands, however, as you’ve found, PDF expert is currently not a reliable context in which to link PDF documents to one’s digital life.

Several other PDF apps support automation (e.g., PDFPenPro, Skim and Preview).

Even aside from Hook, I have been using and recommending Smile Software’s PDFPenPro for years (e.g., at CogZest). PDFPenPro has OCR and form creation for those who need it. Their customer support is excellent. (I’m certainly not saying competitors’ isn’t.) PDFPen development is quite active. Version 12 was recently released (I’m already using it, Pro version).

This isn’t the forum to do product comparisons. However, for customers who value automation and its features, PDFPenPro is worth considering.

Thanks for the pointer to the Integration page. I’ve been using Hook on and off for a while now, but have only just started to look seriously at what it can do.

Ironically I’ve just moved to PDF Expert from PDFPen 6. I’d previously used the Pro version and agree that the OCR works well – plus of course full scriptability :slight_smile:

1 Like