Using Hookmark with PDFoo

PDFoo is a PDF reader developed by One Kerato.

Hookmark 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, Hookmark’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

Hookmark’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 Hookmark. 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
    try
        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 & ")"

When you use Hookmark’s Copy Link or Copy Markdown Link you will get URLs like this: pdfoo://prefix-107/4/@loc/72x/720y/.

Caveats

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 Hookmark to enable hook://file// URLs to be used in PDFoo, which are interoperable.

See also…

PDFoo is discussed on the Hookmark Forum.

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