import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.standard.ColorSupported;
import javax.print.attribute.standard.PrinterName;
public class Main {
public static void main(String[] argv) throws Exception {
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
services = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.GIF, null);
AttributeSet aset = new HashAttributeSet();
aset.add(new PrinterName("HP LaserJet", null));
services = PrintServiceLookup.lookupPrintServices(null, aset);
aset = new HashAttributeSet();
aset.add(ColorSupported.SUPPORTED);
services = PrintServiceLookup.lookupPrintServices(null, aset);
}
}
用Java识别当前计算机中可用的打印服务
最新推荐文章于 2022-07-13 12:02:14 发布
本文提供了一个使用Java打印服务API的示例程序,演示了如何查找可用的打印服务、设置默认打印服务以及指定特定打印机和打印属性进行打印任务。
922

被折叠的 条评论
为什么被折叠?



