java 远程打印机_如何使用Java在网络打印机上打印?

编程入门 行业动态 更新时间:2024-10-25 12:18:15

如果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在网络打印机上打印?

本文发布于:2023-06-14 01:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1424486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机上   如何使用   打印机   网络   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!