【问题标题】:How to get Zebra USB printer status from JAVA如何从 JAVA 获取 Zebra USB 打印机状态
【发布时间】:2015-04-20 11:39:14
【问题描述】:

我的打印机 Zebra TTP 7030 通过 USB 连接到本地计算机。

我可以使用 javax.print API 打印数据,但我无法从打印机获取打印机状态或任何数据。

我试图从 Java printService 属性中获取打印机状态,但它没有返回有关打印机实时状态的任何有价值的信息。

Class<? extends Attribute>[] supportedAttributeCategories = (Class<? extends Attribute>[]) service.getSupportedAttributeCategories();

            for (Class<? extends Attribute> category : supportedAttributeCategories) {
                DocFlavor[] flavors = service.getSupportedDocFlavors();
                for (DocFlavor flavo : flavors) {
                    Object supportedAttributeValues = service.getSupportedAttributeValues(category, flavo, service.getAttributes());
                    if (supportedAttributeValues instanceof Attribute) {
                        Attribute attr = (Attribute) supportedAttributeValues;
                        attribSet.add(attr);
                    } else if (supportedAttributeValues != null) {
                        Attribute[] attrs = (Attribute[]) supportedAttributeValues;
                        for (Attribute attr : attrs) {
                            attribSet.add(attr);
                        }
                    }
                }
            }

            for (Attribute attr : attribSet) {
                System.out.println(attr.getName());

                System.out.println(service.getDefaultAttributeValue(attr.getCategory()));
            }

Zebra 的 Link OS SDK 不支持我的打印机。有没有办法获取打印机状态?

解决方案:我使用JNA 为我的斑马打印机获取 Windows 打印机状态。

这里是如何使用 JNA 获取打印机信息的示例 How can i get a printer's make and model in Java?

【问题讨论】:

    标签: java printing zebra-printers


    【解决方案1】:

    如果 Zebra 打印机仍然使用 ZPL,您可以发送命令,只需打开虚拟 Com 端口并直接发送基于 ZPL 文本的命令

    (使用 Z4000 及以下它工作正常) ~HS 获取状态。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-04
      相关资源
      最近更新 更多