2

Lately, preview on Mac is not saving all the pdf highlights (seen some discussion online about this with no solution yet). I highlight quite a bit of pdfs regularly. The one solution, although extremely inefficient, I found is to save and close the file regularly after 1 or 2 new highlights and open it again. Even with this, unfortunately, the highlights are not saved properly 10 to 20% of the time. Anything more than 2 highlight changes, I am certain they all are not saved 90% of the time.

My question is if there is a keyboard shortcut to open a recently closed preview file? It's a pain to right-click preview every time and open the just-closed file from the list? Any ideas to avoid this problem with preview is also very welcome. Thanks in advance!

2
  • Instead of closing, why not just Save? Hit Cmd-S after every couple/three highlights. Also, I've found Preview only marginally useful when it comes to PDF documents. If you need to highlight/annotate/etc. Use the genuine Adobe Acrobat Reader instead. (it's free)
    – Allan
    Oct 30 '20 at 16:36
  • @Allan Yes, I try to save the pdf after every edit (a habit) but unfortunately, after the first one or two, the later highlights would not be saved. I close and open the file to see this behavior
    – Ajay A
    Oct 30 '20 at 17:05
4

My question is if there is a keyboard shortcut to open a recently closed preview file?

The following was tested in macOS Catalina 10.15.6 and worked for me while Preview has focus. (No third-party applications needed.)

If you just want to open the most recently closed document in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action and assigned a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services can do it.

  • In the Run AppleScript action in the Automator Service/Quick Action, replace the default AppleScript code with the following example AppleScript code:
tell application "System Events" to ¬
    click first menu item of ¬
        menu 1 of menu item "Open Recent" of ¬
        menu 1 of menu bar item "File" of ¬
        menu bar 1 of application process "Preview"

enter image description here


If you want to choose from the Open Recent menu in Preview, then the following example AppleScript code used in a Run AppleScript action in an Automator Service/Quick Action workflow and assigned a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services can do it.

  • In the Run AppleScript action in the Automator Service/Quick Action, replace the default AppleScript code with the following example AppleScript code:
tell application "System Events" to ¬
    set OpenRecentMenuList to ¬
        get name of menu items of ¬
            menu 1 of menu item "Open Recent" of ¬
            menu 1 of menu bar item "File" of ¬
            menu bar 1 of application process "Preview"

if the number of items in OpenRecentMenuList is greater than 2 then
    set OpenRecentList to items 1 thru -3 of OpenRecentMenuList
else
    display dialog "The Open Recent menu is empty." buttons {"OK"} default button 1
    return
end if

set menuItem to (choose from list OpenRecentList) as string

if menuItem is "false" then return

tell application "System Events" to ¬
    click menu item menuItem of ¬
        menu 1 of menu item "Open Recent" of ¬
        menu 1 of menu bar item "File" of ¬
        menu bar 1 of application process "Preview"

enter image description here


I assigned the following keyboard shortcut to the Automator Service/Quick Action in: System Preferences > Keyboard > Shortcuts > Services

enter image description here


Note: The usual security caveats apply. Permissions will need to be granted as prompted and or required in: System Preferences > Security & Privacy > Privacy >


The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted.

5
  • Great! Worked perfectly. Took me a while to implement your idea as I never used automator.
    – Ajay A
    Oct 30 '20 at 17:46
  • Just wanted to add that I assigned Cmd+T (instead of a three key combination like the reply has shown above) for this operation.. This combination did not have any purpose on my system.. So, Cmd+W to close a file and Cmd+T to reopen it.
    – Ajay A
    Oct 31 '20 at 17:10
  • @Ajay A, I initially tried using ⌘R, but it wouldn't work. So I assigned the keyboard shortcuts I did for it to work on my system. Obviously, I can only present examples that work for me, and other users need to do what they want and or what works for them. It's just the nature of the beast. :) Oct 31 '20 at 17:30
  • Agree, it definitely depends on the user.. Did not mean to find fault with your answer but just saying that two key combination could be possible
    – Ajay A
    Oct 31 '20 at 18:23
  • @Ajay A, Not to worry, I didn't anything you said as a negative. I'll will at times when posting an answer such as this even mention issues with keyboard shortcuts and especially global keyboard shortcuts. (I even give details steps at times to, just didn't have time and hoped the pictures would fill in the blanks.) Anyway, I'm glad this is working for you, as I automate as may repetitive tasks as I have to to make things easier. Have a good one! Oct 31 '20 at 20:28
0

There isn't a built-in menu command "Open the last document" (or similar), so there's nothing you can apply a key command to.

You may be able to create an AppleScript that simulates clicking 'the first item' in the "Open Recent" submenu, whatever that may be. You'd then need to trigger that script as a Service with a key command in System Preferences > Keyboard.

To be frank, if Preview is still not behaving 100% of the time with this fix, then you're better off using a different PDF Viewer/editor. Foxit Reader is one of many that are free with highlighting built in, and has many advantages over Preview.

1
  • I like preview as it is very light to use. Will try Foxit Reader/others if this bug is not fixed in the near future.
    – Ajay A
    Oct 30 '20 at 17:51
-1

One way of achieving desired result is to use Finder's Recent window:

  • ⇧-⌘-F: open the Recents window, showing all of the files you viewed or changed recently.
  • open recent file from Recents window
  • make changes, save, close file (⌘-W)
  • ⌘-Tab to make Finder's Recents window active
  • file you opened earlier is selected, press ⌘-O to open it again

Alternatively, if you don't mind closing application altogether and opening it again, close file and application with ⌘-Q and you will be directly back in Recents window where file is selected. Then just open it with ⌘-O.

It's two key presses after closing the file and application. It works on all recents files not only files used with Preview.

To be clear - it works from whatever Finder window. So navigating to file using Finder and opening from there will deliver same results - after closing file (or file along with application) fall back to Finder window and open file again.

1
  • I am really curious: why downvote? It addresses OP-s question (My question is if there is a keyboard shortcut to open a recently closed preview file?) and this keyboard shortcut doesn't require any setup/automator script and whatnot, not to mention that it works on all files. Only requirement is that file should be (initially) opened from Finder. Oct 31 '20 at 6:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .