Skip to content

Instantly share code, notes, and snippets.

@phillymjs
Last active February 2, 2017 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phillymjs/cfd94a9dd97d018e66b109d49c42166d to your computer and use it in GitHub Desktop.
Save phillymjs/cfd94a9dd97d018e66b109d49c42166d to your computer and use it in GitHub Desktop.
AppleScript to fix issues where comments are missing from PDFs. It quits Acrobat Pro, kills the AdobeResourceSynchronizer process and clears some Acrobat caches, forcing comments to be downloaded fresh from the comment server. It is very polite and ensures users save/close any unsaved/open PDFs before it does its dirty work.
on is_running(appName)
tell application "System Events" to (name of processes) contains appName
end is_running
repeat while is_running("AdobeAcrobat")
try
tell application "Adobe Acrobat Pro"
set unsavedDocs to count of (documents where modified is true)
set openDocs to count of documents
end tell
on error
set unsavedDocs to 0
set openDocs to 0
end try
if unsavedDocs > 0 then
if unsavedDocs > 1 then
set plural to "s"
else
set plural to ""
end if
display dialog "You have " & unsavedDocs & " open PDF" & plural & " with unsaved changes. Please save and/or close them to continue." with icon 2 buttons {"Cancel", "Continue"} default button "Continue" with title "Unsaved Changes"
else
if openDocs > 0 then
if openDocs > 1 then
set plural to "s"
else
set plural to ""
end if
display dialog "Please click Continue to quit Acrobat. The " & openDocs & " currently open PDF" & plural & " will be closed. There are no unsaved changes." with icon 2 buttons {"Cancel", "Continue"} default button "Continue" with title "Acrobat Running"
end if
tell application "Adobe Acrobat Pro"
quit
end tell
end if
end repeat
if is_running("AdobeResourceSynchronizer") then
do shell script "killall AdobeResourceSynchronizer"
end if
set userName to short user name of (system info)
set AcroFullVersion to (get version of application "Adobe Acrobat Pro") as text
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set LibraryVersion to text items 1 through 2 of AcroFullVersion as string
set AppleScript's text item delimiters to oldDelims
try
do shell script "rm /Users/" & userName & "/Library/Application Support/Adobe/Acrobat/" & LibraryVersion & "/Acrobat"
do shell script "rm /Users/" & userName & "/Library/Application Support/Adobe/Acrobat/" & LibraryVersion & "/Collab"
end try
display dialog "PDF comments should now load correctly." buttons {"Cool"} default button 1 with icon 1 with title "Comment Cache Purged"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment