To look up the default print service we can use the javax.print.PrintServiceLookup
class lookupDefaultPrintService()
method.
package org.kodejava.print;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
public class GetPrinter {
public static void main(String[] args) {
// Gets the default print service for this environment. Null is returned when
// no default print service found.
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
if (service != null) {
String printServiceName = service.getName();
System.out.println("Print Service Name = " + printServiceName);
} else {
System.out.println("No default print service found.");
}
}
}
The result of the code snippet above:
Print Service Name = HP LaserJet P1005
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024