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 comment
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 comment

@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 comment

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 comment
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 comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...