• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

printing to specific network printer

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Jim Largent
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks..... that worked perfectly
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic