是否可以使用Java打印服务API获得默认的系统打印机?
我可以获得所有打印机的列表
PrintServiceLookup.lookupPrintServices(null, null)但是,如何在系统中选择打印机作为默认选项呢?(在下面的屏幕截图中,检查默认的打印机(HP激光喷气机))。

发布于 2013-01-24 12:21:32
你应该使用PrintServiceLookup
import javax.print.PrintServiceLookup;
PrintService service = PrintServiceLookup.lookupDefaultPrintService(); Acc.致Javadocs:
lookupDefaultPrintService定位此环境的默认打印服务。这可能会返回null。如果每个多个查找服务都指定了一个默认值,则所选择的服务不会被精确定义,但通常会将平台本地服务(而不是已安装的服务)作为默认值返回。如果没有明确可识别的平台本机默认打印服务,则默认值是第一个以依赖于实现的方式定位的。
发布于 2013-01-24 12:19:33
你可以用PrintServiceLookup.lookupDefaultPrintService
PrintService service =
PrintServiceLookup.lookupDefaultPrintService();
if (service != null) {
String printServiceName = service.getName();
System.out.println("Print Service Name is " + printServiceName);
} else {
System.out.println("No default print service found");
}发布于 2013-01-24 12:19:20
PrintService service =
PrintServiceLookup.lookupDefaultPrintService();https://stackoverflow.com/questions/14501170
复制相似问题