Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to distinguish Hardware printer and Software printer

843810Jan 7 2010 — edited Jan 14 2010
Hello,
My Destop application use javax.print.* to detech printer. However, what i get are all the printers that are in Control Panel/Printers and Faxes folder. How can i distinguish hardware printers( real printer) and software printers(got from installing software:Snagit 9, ... ) to remove software printers from printer lists?
My code:
   
        services =
                PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);

        // check for a default service and make sure it is at index 0. the lookupPrintServices does not
        // aways put the default printer first in the array.
        PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
        if (defaultService != null && services.length > 1) {
            PrintService printService;
            for (int i = 1, max = services.length; i < max; i++) {
                printService = services;
if (printService.equals(defaultService)) {
// found the default printer, now swap it with the first index.
PrintService tmp = services[0];
services[0] = defaultService;
services[i] = tmp;
break;
}
}
}

Can i select correct printers from function: PrintServiceLookup.lookupPrintServices with correct conditions?
Thank you.
Minhbt.

Edited by: minhbt on Jan 7, 2010 7:03 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2010
Added on Jan 7 2010
8 comments
177 views