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 发布