File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Cannot get shared printers description

garfild Baram
Ranch Hand

Joined: Mar 24, 2003
Posts: 60
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?
I agree. Here's the link:
subject: Cannot get shared printers description
jQuery in Action, 3rd edition