This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes printing to specific network printer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "printing to specific network printer" Watch "printing to specific network printer" New topic
Author

printing to specific network printer

Jim Largent
Greenhorn

Joined: Feb 17, 2010
Posts: 6
First, let me admit I may be missing something....
I'm developing a web application. I want the authenticated user to be able to submit a form that triggers a printout to a printer that is stored in the database and associated with the user. The printer wont be installed as a printer on the server, so it would be a direct network printer. I've done all the google searching and haven't come up with much which usually means I'm missing something or coming at this wrong. I've seen the examples of getting all the Printer services and then iterating thru the services to find the matching printer, but on a large corporate network that seems to be a lot of processing to first discover everything and then sort thru them for the intended printer. Even if I were to initiate the printing from the client machine, I still have the issue that the printer wouldn't be install on the local machine.
Thanks for any suggestions
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35426
    
    9
Welcome to JavaRanch.

What you can do is -instead of retrieving all available printers through PrintServiceLookup.getPrintServices()- use something like this:

AttributeSet attrSet = new HashPrintServiceAttributeSet(new PrinterName(theUserPrinterName, null));
PrintService ps = PrintServiceLookup.lookupPrintServices(null, attrSet);

substituting "theUserPrinterName" by the printer designation stored for that user. That should return exactly one printer (possibly none, if the printer is not available).


Android appsImageJ pluginsJava web charts
Jim Largent
Greenhorn

Joined: Feb 17, 2010
Posts: 6
Thanks..... that worked perfectly
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: printing to specific network printer
 
Similar Threads
SWT printing works on Windows but not on a Linux machine
Which Linux distro is Java friendly?
No printing with Win XP and AirPort Extreme
Printing issue
Information about installed printer...