aspose file tools*
The moose likes I/O and Streams and the fly likes Cannot get shared printers description Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Cannot get shared printers description" Watch "Cannot get shared printers description" New topic
Author

Cannot get shared printers description

garfild Baram
Ranch Hand

Joined: Mar 24, 2003
Posts: 60
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot get shared printers description
 
Similar Threads
No instance of PrintService is being created
Doubt on Java Print API
Sending some text/image to the printer for printing
How can I send text characters to a printer device ?
Java Print service