importjavax.print.DocFlavor;
importjavax.print.PrintService;
importjavax.print.PrintServiceLookup;
importjavax.print.attribute.AttributeSet;
importjavax.print.attribute.HashAttributeSet;
importjavax.print.attribute.standard.ColorSupported;
importjavax.print.attribute.standard.PrinterName;
publicclassMain{
publicstaticvoidmain(String[]argv)throwsException{
PrintService[]services=PrintServiceLookup.lookupPrintServices(null,null);
PrintServiceservice=PrintServiceLookup.lookupDefaultPrintService();
services=PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.GIF,null);
AttributeSetaset=newHashAttributeSet();
aset.add(newPrinterName("HPLaserJet",null));
services=PrintServiceLookup.lookupPrintServices(null,aset);
aset=newHashAttributeSet();
aset.add(ColorSupported.SUPPORTED);
services=PrintServiceLookup.lookupPrintServices(null,aset);
}
}
用Java识别当前计算机中可用的打印服务
最新推荐文章于 2022-08-09 11:14:04 发布
本文提供了一个使用Java打印服务API的示例程序,演示了如何查找可用的打印服务、设置默认打印服务以及指定特定属性集来筛选打印服务。
921

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



