用java判断打印机打印服务的能力
2009-10-21 18:41
253 查看
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.print.DocFlavor;
import javax.print.StreamPrintService;
import javax.print.StreamPrintServiceFactory;
import javax.print.attribute.Attribute;
public class Main {
public static void main(String[] argv) throws Exception {
OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps"));
DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory
.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
StreamPrintService service = factories[0].getPrintService(fos);
Attribute[] attrs = service.getAttributes().toArray();
for (int j = 0; j < attrs.length; j++) {
String attrName = attrs[j].getName();
String attrValue = attrs[j].toString();
System.out.println(attrName);
System.out.println(attrValue);
}
}
}
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import javax.print.DocFlavor;
import javax.print.StreamPrintService;
import javax.print.StreamPrintServiceFactory;
import javax.print.attribute.Attribute;
public class Main {
public static void main(String[] argv) throws Exception {
OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps"));
DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory
.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
StreamPrintService service = factories[0].getPrintService(fos);
Attribute[] attrs = service.getAttributes().toArray();
for (int j = 0; j < attrs.length; j++) {
String attrName = attrs[j].getName();
String attrValue = attrs[j].toString();
System.out.println(attrName);
System.out.println(attrValue);
}
}
}
相关文章推荐
- java 调用打印机 打印服务
- java调用打印机打印图片
- windows7安装打印机提示“本地打印后台处理程序服务没有运行”
- Java 调用打印机打印图片
- java实现热敏打印机打印小票
- java连接打印机打印PDF
- 打印服务知识系列6--一台物理打印机共享成2个名称
- Java实现POS打印机无驱打印(转)
- java中使用堆栈将字符串逆序打印、判断回文
- JavaWeb开发 JS调用打印机打印全部或局部页面
- JAVA调用系统打印机打印字符串
- 用Java识别当前计算机中可用的打印服务
- java中调用打印机打印本地文件
- java如何调用本地打印机进行图片打印
- [Java]打印机服务程序
- JAVA调用条码打印机打印二维码
- win7局域网连接打印机显示本地打印后台处理程序服务没有运行
- Java 实现 POS 打印机无驱打印
- 打印服务知识系列7--多台物理打印机共享成1个逻辑打印机