Is there a resource showing all the possible syntax for changing the preference file for the preview app in os x? I'm using Catalina if that matters. I frequently copy an image to the clipboard and then command N in preview and then want it to save in PDF format instead of the default PNG format.

defaults write com.apple.Preview


3 Answers 3


Unless you need to edit the image in Preview, I'd suggest leaving it out of the equation altogether.

I use the following python script which saves any image on the clipboard to a PDF file, using a save dialog. (If the file exists, it adds the image as a new page.) You can embed it in an Automator workflow with a Run Shell Script action, or add it to the /Library/Scripts folder, and you can access it using the Scripts menulet. (Script Editor.app Preferences enable the menulet.)


from AppKit import NSPasteboard, NSPasteboardTypePDF, NSPasteboardTypeTIFF, NSPasteboardTypePNG, NSTIFFPboardType, NSPICTPboardType, NSImage, NSSavePanel, NSApp
from Foundation import NSURL
import Quartz as Quartz
import os, syslog

def save_dialog(directory, filename):
    panel = NSSavePanel.savePanel()
    print (panel)
    panel.setTitle_("Save clipboard")
    myUrl = NSURL.fileURLWithPath_isDirectory_(directory, True)
    ret_value = panel.runModal()
    if ret_value:
        return panel.filename()
        return ''

def main():
    destination = os.path.expanduser("~/Desktop/")
    outfile = save_dialog(destination, "Clipboard.pdf")

    myFavoriteTypes = [NSPasteboardTypePDF, NSPasteboardTypeTIFF, NSPasteboardTypePNG, NSTIFFPboardType, NSPICTPboardType, 'com.adobe.encapsulated-postscript']
    pb = NSPasteboard.generalPasteboard()
    best_type = pb.availableTypeFromArray_(myFavoriteTypes)
    if best_type:
        clipData = pb.dataForType_(best_type)
        if clipData:
            image = NSImage.alloc().initWithPasteboard_(pb)
            if image:
                page = Quartz.PDFPage.alloc().initWithImage_(image)
            if os.path.exists(outfile):
                pdfURL = NSURL.fileURLWithPath_(outfile)
                myFile = Quartz.PDFDocument.alloc().initWithURL_(pdfURL)
                if myFile:
                    pagenum = myFile.pageCount()
                    myFile.insertPage_atIndex_(page, pagenum)
                    print ("Image added to Clipboard file.")

                pageData = page.dataRepresentation()
                myFile = Quartz.PDFDocument.alloc().initWithData_(pageData)
            print ("Clipboard file created.")

        print ("No clipboard image data was retrieved.")
        print ("These types were available:")
        print (pb.types())

if __name__ == "__main__":
  • Thank you! I do need to edit it but this script will be very helpful in some other uses I have.
    – Steve
    Oct 26, 2019 at 0:23

You can bind a non-occupied shortcut like cmd+shift+E to the menu item Export as PDF... in Keyboard preferences under app shortcuts.

You'll anyway use cmd+S to save it, just one more key gives this exported as PDF. You might need to remove .png from the file name.

If resizing is a step somewhere, and is very frequent, as pointed out by @benwiggy, using shortcuts for Export.. is a good idea. You might want to see in some .plist files about setting the default format to be PDF, not PNG.

If it is not so frequent, you can use Spotlight to find the file, use cmd+enter to reveal it in Finder and crop it using cmd+shift+A (Show markup toolbar). Then mark the rectangle and use cmd+K to crop and save it.

  • 1
    I thought of that after posting the question. I think it's the best work around for this. I just use command+shift S
    – Steve
    Oct 26, 2019 at 0:24

Please make sure you have a backup and know how to use it or reverse this. There is a kind comment explaining they have seen issues. I have done this many times on many OS up to and including Catalina here, but YMMV.

Map Command + S to Export as PDF... in Keyboard Shortcuts to change the default save format.

Set a custom Keyboard shortcut for Preview

Same as with Pages or most other apps Apple has a menu item for this option. You could get fancier and just make an automator script to pull the clipboard contents and save as PDF and skip invoking Preview, and needing to press Command N as well, but remapping the S command is the easy fix you can do today.

  • Note that "Export as PDF" places the image on the default printer page size. "Export..." selecting "PDF" from the dropdown list saves the image at its natural size. I think automating something (though Automator has no "save image" action) or using something other than Preview is the way forward.
    – benwiggy
    Oct 24, 2019 at 14:20
  • Cool solution in python @benwiggy . I agree with you above - I wouldn't go in Preview either, but that's what the OP asked. Since there isn't a defaults pref documented to set, this may be the only way "with" preview.
    – bmike
    Oct 24, 2019 at 14:55
  • Did you actually test that this modification works? Aside from the fact that ⌘S is already assigned to both Save and Save…, depending on the state of the file opened in Preview (and possibly the version of macOS), one should not just assign an already assigned keyboard shortcut to another command without first changing its original assignment(s). For example, one would have to assign both Save and Save… to e.g. ^⌘S and then assign Export as PDF… to e.g. ⌘S for this to work properly. Oct 24, 2019 at 16:32
  • 1
    That said, I wouldn't do it and just assign a different unused keyboard shortcut to Export as PDF… e.g. ^⌘E and use that when wanting to export to PDF if wanting to do this is Preview. Oct 24, 2019 at 16:32
  • @user3439894 Of course I tested it. Worked for three sample images for me. I disagree and override command S on all sorts of ways and times. I get it's not your cup of tea, but there's been no issue with me overriding that - especially for one and only one app for the past 10 years or more. I appreciate the comments - hopefully this helps you and others.
    – bmike
    Oct 24, 2019 at 23:23

You must log in to answer this question.

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