This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages 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
Hi,
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(MediaSizeName.ISO_A4);
aset.add(new Copies(2));
aset.add(Sides.TWO_SIDED_LONG_EDGE);
PrintService[] services = PrintServiceLookup.lookupPrintServices (DocFlavor.SERVICE_FORMATTED.PRINTABLE,null);
if(services.length>0){
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();
try{
job.print(myDoc,aset);
}
catch(PrintException pe){
System.out.println(pe.getMessage());
}
}
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?
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic