Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot get shared printers description

garfild Baram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to do a print job and my code is as follows:

DocFlavor myFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc myDoc = new SimpleDoc(textStream,myFormat,null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(2));
PrintService[] services = PrintServiceLookup.lookupPrintServices (DocFlavor.SERVICE_FORMATTED.PRINTABLE,null);
String services.getClass().getName();
int printerIndex=0;
for(int i=0; i<services.length;i++){
if(services[i].getName().equals (printerDescription)){
printerIndex = i;
DocPrintJob job = services[printerIndex].createPrintJob();
catch(PrintException pe){
The printjob works well but not for shared printers.
If printerDescription will hold the printer shared name it won't work, meaning, PrintService[] does not hold printer shared name.
How can I over come it?
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!