jscooper Posted January 15, 2003 Posted January 15, 2003 Here's my answer to selecting a printer tray on a Mac. It uses AppleScript. Maybe there's a more elegant solution, but I coudn't find one in a hurry. For the past several days, I've been trying to get a Mac running 5.5 to select a particular printer tray for printing labels. I looked into modifying a PPD to make it only use a particular tray, but I was still stuck as far as making it work relatively seamlessly for the user. (OK, truth be told, I couldn't make heads or tails of what was going on in the PPD, mine didn't look anything like the one in the examples I've seen.) Anyway, then I noticed that there's a LaserWriter 8 Prefs file in Preferences:Printing Prefs. And I said "A-HA!" For the record, we're on an iMac running 9.2 printing to a Laserjet 2100 (ML I think) which is available when you choose LaserWriter 8 in the Chooser. I've only tried it on the one kind of printer, so I don't know if this will work in all, most or even some cases. But it worked for me. Here's what I did: Go into System Folder:Preferences:Printing Prefs. Duplicate the file LaserWriter 8 Prefs. Rename the original LaserWriter 8 Prefs file to LaserWriter 8 PrefsOrig. Rename LaserWriter 8 Prefs Copy to LaserWriter 8 Prefs. Print something to bring up the print dialog. In the tray selection menu, change it from your usual setting (ours was set to "autoselect") to the setting you want to use (in our case, Tray 2 of a three tray printer). Click Save Settings and click OK when asked to confirm. Now, click cancel to close the print dialog. Go back to the Finder and change the file names again: Rename LaserWriter 8 Prefs LaserWriter 8 PrefsT2. (this is so I'll remember it's set to "tray 2") Rename LaserWriter 8 PrefsOrig to LaserWriter 8 Prefs. If you like, print something again and you'll see the settings are back to what they were before you started. Now, go into FileMaker, bring up the script that contains the print job. Let's say it looks like this: Print Setup [Restore, No Dialog] Print [No Dialog] You'll want to add two Perform AppleScript steps both before and after the Print step. These will flip back and forth between the two settings (Tray2 and whatever you're default is): Print Setup [Restore, No Dialog] Perform AppleScript Print [No Dialog] Perform AppleScript The first Perform AppleScript step will rename the two preference files. Perform AppleScript: tell application "Finder" try set p to (path to system folder as text) & "Preferences:Printing Prefs:LaserWriter 8 Prefs" set name of file p to "LaserWriter 8 PrefsOrig" end try try set p to (path to system folder as text) & "Preferences:Printing Prefs:LaserWriter 8 PrefsT2" set name of file p to "LaserWriter 8 Prefs" end try end tell The second will change them back after printing: Perform AppleScript: tell application "Finder" try set p to (path to system folder as text) & "Preferences:Printing Prefs:LaserWriter 8 Prefs" set name of file p to "LaserWriter 8 PrefsT2" end try try set p to (path to system folder as text) & "Preferences:Printing Prefs:LaserWriter 8 PrefsOrig" set name of file p to "LaserWriter 8 Prefs" end try end tell I would also suggest adding Set Error Capture [On] before printing so it'll still finish the script and reset the preference files in case anything goes wrong. Also, if you want to get fancy, you can probably change the AppleScript to better handle things if there's no second preference file. In my example, it'll probably just go with whatever the defaults are. Jeff
BobWeaver Posted January 15, 2003 Posted January 15, 2003 Excellent idea! And much simpler than monkeying around with ppd files.
Recommended Posts
This topic is 7974 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now