java 打印换列,如何在java中访问打印机队列

Suppose that I printed some documents from a program like MS Word. Let's say I selected 4 documents at once, so three of them would end up waiting in the printer queue. I would like to access and read some information about the documents waiting in the queue. In other words, how can I access the printer queue and read information about any pending files with java?

Is there a way to do that? If so, how can I do it?

Thanks for the help

解决方案

maybe this function helpful for you.

public Integer getExistQueuePrinter() {

int queue = 0;

PrintService myService = null;

PrintService printService = PrintServiceLookup.lookupDefaultPrintService();

if (printService != null) {

//--> set printService.

myService = printService;

//--> get attributes from printService.

AttributeSet attributes = printService.getAttributes();

//--> loop attributes.

for (Attribute a : attributes.toArray()) {

String name = a.getName();

String value = attributes.get(a.getClass()).toString();

//System.out.println(name + " : " + value);

if (name.equals("queued-job-count")) {

//System.out.println(name + " : " + value);

queue = Integer.parseInt(value);

}

}

Object[] obj = attributes.toArray();

//System.out.println("queue = " + obj[3]);

return queue;

/* debug.

for (Object value : obj) {

System.out.println("Color = " + value);

}

*/

}

return null;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值