This script opens the DEVONthink record for the PDF currently viewed in Adobe Acrobat Pro.
If it doesn’t find the PDF’s path in one of the open DEVONthink databases it displays a notification.
Properties
- property
useCurrentPage
: Open DEVONthink record to the page currently viewed in Adobe Acrobat Pro.
Example
PDF viewed in Adobe Acrobat Pro:
Script result:
-- Open DEVONthink record for Adobe Acrobat Pro tab
property useCurrentPage : true
tell application id "com.adobe.Acrobat.Pro"
try
set theWindows to windows
if theWindows = {} then error "Please open a window"
set theWindow to item 1 of theWindows
set theHFSPath to (file alias of active doc of theWindow) as string
if theHFSPath = "" then error "Please select a PDF tab"
set thePageNumber to page number of item 1 of PDF Windows of active doc of theWindow
on error error_message number error_number
if the error_number is not -128 then display alert "Adobe Acrobat Pro" message error_message as warning
return
end try
end tell
set thePath to POSIX path of theHFSPath
tell application id "DNtp"
try
set theDatabases to databases
set theResults to {}
repeat with thisDatabase in theDatabases
set thisDatabasesResults to lookup records with path thePath in thisDatabase
set theResults to theResults & thisDatabasesResults
end repeat
if theResults = {} then
display notification "PDF is not in open databases" with title "Lookup DEVONthink"
return
else
if useCurrentPage then
set theReferenceURL_withCurrentAdobePage to (reference URL of (item 1 of theResults)) & "?page=" & (thePageNumber - 1)
do shell script "open " & quoted form of theReferenceURL_withCurrentAdobePage
else
open window for record (item 1 of theResults)
activate
end if
end if
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell