Getting a PDF selection link via AppleScript

As far as I know, there are no way to get this new kind of link via AppleScript, only via GUI. So, I tried to compile without GUI

  1. base link - no problem
  2. page number is a current page property of window
  3. search string you can make using escapeURL command from Satimage scripting addition, or using AppleScript ObjC
  4. length is the characters value of selected text property
  5. The only thing I don’t know - is how to get the start value, as the number of the first selection char from the beginning of the document?


1 Like

You don’t need the Satimage or ASOC to percent encode text.

tell application id "DNtp" to do JavaScript "encodeURIComponent(\"jim is cool\")" in think window 1
--> "jim%20is%20cool"
1 Like

It is good that you can use just “page and search”, but “start and length” solution is more stable because the search phrase may not be unique for this page.

So, is there a way to get the start char number?
Or waiting for “selection link” AppleScript function in the next release? )

Actually it will be a reference URL property for tabs/windows :wink:


Using this tip…

…this is another possibility:

encodeURIComponent("Just a test")

on encodeURIComponent(uri as text)
	run script "encodeURIComponent(" & (the quoted form of uri) & ");" in "JavaScript"
end encodeURIComponent