Forum Moderators: travelin cat

Message Too Old, No Replies

Web Page Printing

How do you direct printing

         

HeadBut

9:37 pm on Oct 19, 2004 (gmt 0)

10+ Year Member



I have a web site on an intrAnet with several printers and I want to control what printer a page gets printed on.. like some pages only to the black and white printer and some pages to the colour printer.
OS X/Apache/PHP/MYSQL

Anyone done this?

Thanks

whoisgregg

10:20 pm on Oct 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm pretty sure it's impossible. Hopefully someone can prove me wrong because I annoy my boss every time I print dozens of pages of B&W code to our big color laser printer.

To clarify further, I know it's not possible to control the printer through the web site/page itself. If it's possible at all, it would be software based on each machine or controlled through a print server (if you have one setup.)

HeadBut

9:19 pm on Oct 20, 2004 (gmt 0)

10+ Year Member



ok, is there a print server directive that can route printing based on something like source IP or User group... or something?

There has gotta be a way to do this!

Thanks

whoisgregg

10:16 pm on Oct 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Applescripts and a shell script can do this as long as you can train your people to use the "Print" Applescript instead of File > Print.

I don't understand all the lpr stuff, but a man lpr in terminal sure makes it look possible.


tell application "Safari"
set this_URL to the URL of document 1
if this_URL contains "special_color_directory" then
display dialog "color printer"
-- insert lpr shell script targeting color printer here
else
display dialog "black and white printer"
-- insert lpr shell script targeting b&w printer here
end if
end tell

timster

2:12 pm on Oct 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm...since this is an intranet, you could have a server do the actual printing instead of the client machine. Have a "print this page" button run an AppleScript CGI that would select the printer like Greg showed.

Sounds like a bit of work, and might place demands on your server hardware, though.

whoisgregg

2:36 pm on Oct 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here we go, here's some better Applescript to choose the default printer:

property x : 1 -- printer number
tell application "Printer Setup Utility"
set myprinters to get printers
set current printer to item x of myprinters
-- quit
end tell

whoisgregg

2:42 pm on Oct 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And the final script, you may want to juggle around the order of the testing of color or black and white.

property x : 1 -- black and white printer number
property y : 2 -- color printer number
tell application "Safari"
set this_URL to the URL of document 1
if this_URL contains "black_and_white_dir" then
tell application "Printer Setup Utility"
set myprinters to get printers
set current printer to item x of myprinters
quit
end tell
else
tell application "Printer Setup Utility"
set myprinters to get printers
set current printer to item y of myprinters
quit
end tell
end if
print document 1
end tell

whoisgregg

2:55 pm on Oct 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Adding the Script to the Scripts Menu:

1. Put the above script in this folder:
~/Library/Scripts/Applications/Safari/

2. Run this file:
Applications/AppleScript/Install Script Menu

3. Select "Hide Library Scripts" from the script menu.
(optional, to reduce confusion)