如果Java AWT Printing未注册到运行打印应用程序的Windows / Active Directory用户,则它将无法通过路径找到该打印机.您必须通过Windows“设备和打印机”将打印机路径注册为该用户的打印机,以使其可见.然后,您必须运行lookupPrintServices以查看可用的打印机列表,并按列出的确切名称String检索正确的PrintService.
/**
* Retrieve the specified Print Service; will return null if not found.
* @return
*/
public static PrintService findPrintService(String printerName) {
PrintService service = null;
// Get array of all print services - sort order NOT GUARANTEED!
PrintService[] services = PrinterJob.lookupPrintServices();
// Retrieve specified print service from the array
for (int index = 0; service == null && index < services.length; index++) {
if (services[index].getName().equalsIgnoreCase(printerName)) {
service = services[index];
}
}
// Return the print service
re
更多推荐
java 远程打印机_如何使用Java在网络打印机上打印?
发布评论