How to print from Google Docs in Safari

applescriptpdfprintingsafari

For some reason when I press CMD + P or go to File>Print in Google Doc's instead of printing, the document is downloaded as a PDF. I then have to navigate to my downloads folder, open the PDF, and print it through Preview.

This only occurs in Safari. If I press CMD + P or File>Print in Chrome, the Chrome print dialog box comes up immediately and I am able to print directly from Chrome.

How can I get the print dialog to popup directly in Safari? Or if that can't be done is there a way to automatically identify that a document has been downloaded from Google Docs and print it? Maybe with an Apple Script?

Best Answer

I have not found a way to get the print dialog box to appear in Safari. Instead I have created a script that will check when something is downloaded and see if it is from Google Docs. If it is then the document will be opened in Preview with the print dialog box. Basically giving you similar functionality you have in Chrome. You can then print it as you normally would.

Here's the script. Save it to /Library/Scripts/Folder Actions Scripts/:

on adding folder items to this_folder after receiving added_items
    repeat with i in added_items
        set myPath to the POSIX path of i
        if myPath ends with ".pdf" then
            set myLocation to (do shell script "mdls -name kMDItemWhereFroms " & the quoted form of myPath)
            if myLocation contains ".google.com" then
                tell application "Preview"
                    activate
                    print i with print dialog
                end tell
            end if
        end if
    end repeat
end adding folder items to

The script will need to be added as a Folder Action. Follow instructions below:

  1. Navigate to the Downloads folder

  2. Right click on the Downloads folder and select Services>Folder Actions Setup

  1. Select the script that saved and click Attach

  2. Make sure Enable Folder Actions is checked in the upper left

  3. Test a Google Doc