importjava.io.BufferedInputStream;
importjava.io.BufferedOutputStream;
importjava.io.FileInputStream;
importjava.io.FileOutputStream;
importjava.io.InputStream;
importjava.io.OutputStream;
importjavax.print.DocFlavor;
importjavax.print.StreamPrintService;
importjavax.print.StreamPrintServiceFactory;
importjavax.print.attribute.Attribute;
publicclassMain{
publicstaticvoidmain(String[]argv)throwsException{
OutputStreamfos=newBufferedOutputStream(newFileOutputStream("filename.ps"));
DocFlavorflavor=DocFlavor.INPUT_STREAM.GIF;
StreamPrintServiceFactory[]factories=StreamPrintServiceFactory
.lookupStreamPrintServiceFactories(flavor,DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
StreamPrintServiceservice=factories[0].getPrintService(fos);
Attribute[]attrs=service.getAttributes().toArray();
for(intj=0;j<attrs.length;j++){
StringattrName=attrs[j].getName();
StringattrValue=attrs[j].toString();
System.out.println(attrName);
System.out.println(attrValue);
}
}
}
用java判断打印机打印服务的能力
最新推荐文章于 2021-03-26 15:12:14 发布