JavaPOS 打印文本抛出 JposException

标签 java applet javapos

我在设置小程序以与 Epson TM-T88V pos 打印机配合使用时遇到了很多麻烦。现在我可以发送切割机命令并且它可以工作。但无法打印任何其他文本。

发生以下 jpos.JposException:

jpos.JposException: UnicodeDLL:-10An undefined parameter value was set.  
  at jp.co.epson.upos.T88V.pntr.T88VService.createNormalData(Unknown Source)  
  at jp.co.epson.upos.core.v1_13_0001.pntr.CommonPrinterService.executeNormalPrint(Unknown Source)  
  at jp.co.epson.upos.T88V.pntr.T88VService.printNormal(Unknown Source)  
  at jpos.POSPrinter.printNormal(Unknown Source)  
  at de.develman.pos.printer.Printer.printReceipt(Printer.java:58)  
  at de.develman.pos.ui.action.PrintAction.actionPerformed(PrintAction.java:22)  
  at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)  
  ...

我的代码如下所示:

private void initPrinter() throws JposException {
    ptr.open("POSPrinter");
    ptr.claim(1000);
    ptr.setDeviceEnabled(true);
    ptr.setMapMode(POSPrinterConst.PTR_MM_METRIC);
}

private boolean printerUseable() throws JposException {
    // check if the cover is open
if (ptr.getCoverOpen() == true) {
    // cover open so do not attempt printing
    System.out.println("printer.getCoverOpen() == true");
    return false;
}

// check if the printer is out of paper
if (ptr.getRecEmpty() == true) {
    // the printer is out of paper so do not attempt printing
    System.out.println("printer.getRecEmpty() == true");
    return false;
}

    return true;
}

public void printReceipt() {
    try {
        initPrinter();
        if (printerUseable()) {
            ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, "1\n");
            ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, PAPERCUT);
        }
    } catch (JposException e) {
        // display any errors that come up
        e.printStackTrace();
    } finally {
        // close the printer object
        try {
            ptr.setDeviceEnabled(false);
            ptr.release();
            ptr.close();
        } catch (Exception e) {
    }
}

异常指向以下行:

ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, "1\n");

如果我从 eclipse 运行代码,一切都会正常。如果我去掉线,切割器就可以正常工作。但是如果我想打印任何文本,则会抛出给定的异常。
我的问题是什么?

最佳答案

我已经使用 Epson TM-T88V 打印机实现了 JavaPOS,并且遇到了相同的错误,但我能够使用此链接中的示例代码解决该错误:

http://jpos.1045706.n5.nabble.com/file/n2250344/StarReceiptTest.java

查看启动和终止打印事务的部分。

希望有帮助。

关于JavaPOS 打印文本抛出 JposException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14799758/

相关文章:

java - java中如何过滤输入文本中的特殊字符以防止XSS攻击?

java - 3.13 版中缺少 Apache POI hslf?

java - 使用 Rserve 时由于错误太大而丢弃缓冲区

java - 如何(简单地)从java生成POST http请求来上传文件

java - 使用 Visual Basic 的 Java Applet 接口(interface)

java - Windows 中 Epson POS 打印机的 JPOS 配置问题

java - 如何使用 Java 和 EPSON TM-T88III 打印凭证

java - 我们可以使用来自android的数据通过Javascript在webview中显示它吗?

java - 从 JS 调用时的小程序权限

java - 在 JPOS.xml 中添加 PDF 打印机