Jump to content

Why is it so difficult to make workflow to print a specific document?

Recommended Posts

Excuse my newbie frustration here.

I though it would be the most simple workflow but I cannot figure this out.


I have a specific document which I need a hard copy of once or twice a month to print out to my default printer. I would love to have a hotkey to just do this. Why is it so hard?

It is a pages doc and I figured out how to open the file in pages, but it would appear that printing requires scripting knowledge beyond my expertise.


It seems like such a basic need I don't understand why this is so difficult.


Thanks for any help.

Link to post
34 minutes ago, Leighton said:

It seems like such a basic need I don't understand why this is so difficult.


TBH, this question has little to do with Alfred. You’re asking about Pages automation, which is a Pages question.


There is no universal “print document” command.


You need to figure out, or—ideally—find, an AppleScript to tell Pages to open and print your document.


Once you’ve got that, then you can  easily configure Alfred to run it for you.

Link to post

@Leighton As @deanishe says, this is actually a pretty complex issue. One option is to simplify the problem by making the document more generic. If you export it as a PDF, then there are more options available for printing (even if they aren't perfect).


Once you have a pdf, you could use the lpr command with a HotKey object connected to a Run Script object in an Alfred workflow. For example, if the document was called test.pdf on your desktop, the command would be lpr ~/Desktop/test.pdf


Rather than giving more examples, here is a forum thread I found which discusses the issue (and highlights that it's not as simple as one may think):






Link to post

I actually had some luck with a very simple apple script.


As I mentioned above I had figured out how to use Alfred commands to have a hot key open the document in the application Pages

I thought - If I print this manually all I'm doing is typing command-p and then when the print dialog box pops up typing enter, so what if a simple keystroke script would work - and it did! I Found this script online:


tell application "Pages"
	delay 0.2
	tell application "System Events" to keystroke "p" using {command down}
	tell application "System Events" to key code 36
end tell

Now I just need a command to quit the application. and I'm golden.


Link to post
8 hours ago, deanishe said:

The problem is that there are thousands and thousands of different types of documents.


In order to print one, you need an application that can read your document to convert it into something a printer (driver) can understand.

Just use a one line AppleScript

tell application "Finder" to print selection

this will print using whatever the system default app for the file type is.  Works fine for Pages for me.


Or in an Alfred file action where Language is AppleScript and input is {query}:

tell application "Finder" to print POSIX file "{query}"


Edited by dfay
Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...