Using Hook with PDFoo

PDFoo is a PDF reader developed by One Kerato.

Hook works “out of the box” with PDFoo, enabling you to link PDF files to and from anything that is also linkable.

Copy Link, Copy Markdown Link and Hook to Copied Link

By default, Hook’s Copy Link and Copy Markdown Link in PDFoo return links of the form hook://file//. You can paste those links anywhere. You can move and rename the files and the links will normally still work.

Deep Links with PDFoo

Hook’s built in integration with PDFoo does not yet support deep linking. (It does support deep linking with some other PDF apps.)

If you would like to get deep links to PDF files in PDFoo you can replace the default integration script with the one below. It uses UI scripting so it is not as robust as the built-in integration with Hook. However please see caveats below.

use scripting additions
use framework "Foundation"

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 the clipboard to ""
delay 0.5
tell application "System Events" to keystroke "c" using {command down}
repeat 60 times -- poll clipboard for ~2.5 seconds
        set theSelectedText to the clipboard

        if theSelectedText is not equal to "" then
            exit repeat
        end if
    end try
    delay 0.05
end repeat
tell application "System Events"
    tell (process 1 whose frontmost is true)
        set pdfUrl to value of attribute "AXDocument" of window 1
        set AppleScript's text item delimiters to {"/"}
        set fn to last text item of pdfUrl
    end tell
end tell

tell application "System Events"
    tell process "PDFoo"
        set myTitle to name of window 1
    end tell
end tell
if theSelectedText is not "" then
    set AppleScript's text item delimiters to {"pdfoo://"}
    set pdfUrl to "pdfoo://" & last text item of theSelectedText
    set AppleScript's text item delimiters to {" "}
    set pdfUrl to first text item of pdfUrl

end if
return "[" & urlDecode(fn) & "](" & pdfUrl & ")"

In that case when you call Hook’s Copy Link or Copy Markdown Link you will get URLs like this: pdfoo://prefix-107/4/@loc/72x/720y/ .


These links are not interoperable in the sense that you can’t simply switch to a different PDF reader as you can with hook://file// URLs (deep PDF links).

In the future we, CogSci Apps Corp., will likely enhance Hook to enable hook://file// URLs to be used in PDFoo, which are interoperable.

See also…

PDFoo is discussed in the Hook Productivity Forum.

Other alternatives for deep linking to PDFs are discussed on our blog: Deep PDF Links Take You Right Where You Need to Focus – Hook.