wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes How to get List of Client Printers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to get List of Client Printers" Watch "How to get List of Client Printers" New topic
Author

How to get List of Client Printers

Rayudu addagarla
Ranch Hand

Joined: Aug 17, 2000
Posts: 39
I would like to retrieve the list of printers attached to the clients machine, thru. my java application.
Is there any method in Java API which returns the list of printers attached. If there is any third party tool which supports this
thanks
raj madhuram
Ranch Hand

Joined: Oct 10, 2001
Posts: 71
Hi,
This might help
http://www-106.ibm.com/developerworks/java/library/j-mer0322/
regards,
Raj
Rayudu addagarla
Ranch Hand

Joined: Aug 17, 2000
Posts: 39
thanks raj,
that was really fast ...
i will go thru that.
Rayudu addagarla
Ranch Hand

Joined: Aug 17, 2000
Posts: 39
Got it worked..
thanks once again!!!
for those who might need the code.
import javax.print.*;
import javax.print.attribute.*;
import java.io.*;
public class Printing {
public static void main(String args[]) throws Exception {
//String filename = args[0];
PrintRequestAttributeSet pras =
new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.PNG;
PrintService printService[] =
PrintServiceLookup.lookupPrintServices(flavor, pras);
for (int i=0;i<printService.length;i++)
{
System.out.println (printService[i].toString());
}
/*PrintService defaultService =
PrintServiceLookup.lookupDefaultPrintService();
PrintService service = ServiceUI.printDialog(null, 200, 200,
printService, defaultService, flavor, pras);
if (service != null) {
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(filename);
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
job.print(doc, pras);
Thread.sleep(10000);
}
*/
System.exit(0);
}
}
/* for those who want to print document remove comments.
*/
Rayudu
Rayudu addagarla
Ranch Hand

Joined: Aug 17, 2000
Posts: 39
Sorry guys forgot to tell
its only in jdk1.4
import javax.print.*;
Rayudu
 
GeeCON Prague 2014
 
subject: How to get List of Client Printers