用 Java 连接并打印到打印机 [英] Connecting and printing to a printer in Java

查看:221
本文介绍了用 Java 连接并打印到打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 中是否有一种简单的方法可以执行以下操作?

Is there an easy way in Java to do the following?

  1. 连接到打印机(将是本地打印机,并且是唯一连接到机器的打印机).
  2. 在 2 个不同的打印机托盘中打印 2 页的页面.
  3. 获取当前的打印队列计数,即我有 100 个项目要打印,当前已打印 34 个,打印机队列现在应为 66.

推荐答案

一些快速提示:

打印作业的状态:您可以使用 PrintJobListener:

status of printing job: you might be able to get something useful by using a PrintJobListener:

这个监听器的实现接口应附加到DocPrintJob 监控状态打印机作业.这些回调可以在线程上调用方法处理打印作业或服务创建通知线程.在任一客户不应该执行的情况这些回调中的冗长处理.

Implementations of this listener interface should be attached to a DocPrintJob to monitor the status of the printer job. These callback methods may be invoked on the thread processing the print job, or a service created notification thread. In either case the client should not perform lengthy processing in these callbacks.

这篇关于用 Java 连接并打印到打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆