|
|
#1 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,039
|
Print to print queue from Finder trouble
I'm trying to create a Service that will print the selected documents in the Finder, by launching them in their default apps and printing them to a specified print queue without opening the print dialog (i.e. no user input required).
Here's the AppleScript code in Automator: Code:
on run {input, parameters}
set NumFiles to count of items of input
repeat with i from 1 to NumFiles
set some_item to item i of input
try
tell application "System Events"
print some_item with properties {target printer:"Direct PDF"} without print dialog
end tell
end try
end repeat
return input
end run
The only feedback I'm getting is: 16/06/2012 17:14:34.359 com.apple.automator.xpc.workflowServiceRunner: 2012-06-16 17:14:34.357 WorkflowServiceRunner[6801:1707] Could not connect the action buttonPressed: to target of class NSApplication in the Console. EDIT: Actually, I don't know how quickly the Services menu "updates" itself. I changed the name of a service and the change wasn't implemented after logging out and in again. Restarting the LS database seems to have really knackered things. Last edited by benwiggy; 06-16-2012 at 12:20 PM. |
|
|
|
|
|
#2 |
|
Hall of Famer
Join Date: Apr 2003
Posts: 2,662
|
What your doing sounds like more fun/interesting. But why not highlight the document and choose the Print option? It just prints and does not invoke the print dialog box.
|
|
|
|
|
|
#3 | |||||||||||||||||||||||
|
League Commissioner
Join Date: Aug 2006
Posts: 5,039
|
Because that sends the job to the default (or currently selected) printer. I want the print queue to be determined by the Service. Also, some apps DO show the print dialog when you do <Command> P in the Finder. And there's a bug that affects printing from the Finder to Preview. |
|||||||||||||||||||||||
|
|
|
|
|
#4 |
|
Major Leaguer
Join Date: Apr 2010
Posts: 324
|
Found this on another website. Seems to work for RTF files. Wasn't able to get it to work with docx files.
Using -h flag gives some lists command options. Code:
/System/Library/Printers/Libraries/convert -f file.rtf -o file.pdf -j "application/pdf"
__________________
see a problem; solve a problem. |
|
|
|
|
|
#5 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,039
|
The convert command only works for file formats that OS X can handle -- e.g. stuff that Preview can open, Office formats, etc.
And while it does convert those files to PDF (which you've correctly noticed is the purpose of the print queue in my AppleScript), I'm looking for a general solution, as I want different Services for different print queues (or one big mother of a Service that can specify the print queue). Last edited by benwiggy; 07-08-2012 at 01:48 AM. |
|
|
|
|
|
#6 |
|
Hall of Famer
Join Date: Mar 2002
Posts: 3,870
|
I'm just guessing, but here goes: when I go to System Preferences: Printers, and double click on my printer, it shows up in my dock. I can drag and drop any document to the dock icon and it shows up in the print queue. I have tried a few different types of files and I haven't seen any dialog boxes yet.
Now, when I click on the dock icon and go to the print queue window, then control-click on the title I see the queue is located in ~/Library/Printers. Opening that folder shows me the print queue icon with the suffix .app So maybe your AppleScript could just open the selected file with the app that is the print queue. If you don't want to use the defaults for that print queue you could make another print queue in System Preferences, which would be a different app, and change the defaults for that one. |
|
|
|
|
|
#7 | |||||||||||||||||||||||
|
League Commissioner
Join Date: Aug 2006
Posts: 5,039
|
I get the app's dialog box with formats that aren't OS X native. |
|||||||||||||||||||||||
|
|
|
|
|
#8 |
|
Hall of Famer
Join Date: Dec 2007
Posts: 3,642
|
I'm guessing this won't appeal to you, benwiggy, but I'll put it out there in case that's incorrect. With Keyboard Maestro you could create a macro which executes your script and handles things without user input in the event that the print dialog appears due to the file type selected. This is based on a macro action Maestro has called If Then Else. In simple terms, by using this action you could configure things such that Maestro will handle what needs to be done if it's a file type which includes the print dialog. All told, you'd have a process that looks something like this:
If that approach is even a consideration for you, Keyboard Maestro offers a 30-day trial. If you try it and need any help configuring the macro, I'd be happy to help. |
|
|
|
|
|
#9 |
|
League Commissioner
Join Date: Aug 2006
Posts: 5,039
|
I do use iKey, which is a similar thing to Keyboard Maestro.
Thanks for the various ideas, but I was hoping to create the Service to work on any Mac. I might look at another way of doing it, as it does seem that there is variation across different app's handling of the print applescript command. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|