【问题标题】:JavaPOS printing text throws JposExceptionJavaPOS 打印文本抛出 JposException
【发布时间】:2013-01-25 19:46:14
【问题描述】:

我在设置小程序以与 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 运行代码,一切正常。如果我删除线,切割器工作正常。但是如果我想打印任何文本,就会抛出给定的异常。
我的问题是什么?

【问题讨论】:

    标签: java applet javapos


    【解决方案1】:

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

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

    查看开始和终止打印事务的部分。

    希望对你有帮助。

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。

      为解决此问题,我已卸载 Epson JavaPOS-ADK 并重新安装。再次重新安装 ADK 时,我检查了我是否选择了正确的 jpos.xml(我也在我的应用程序中使用的那个 jpos.xml)。之后错误消失了......

      希望这可以帮助其他有同样问题的人...

      【讨论】:

        【解决方案3】:

        这里有同样的问题,其他答案对我的问题没有帮助。

        我能够通过以下步骤在 Win 10 64 上安装 Epson_JavaPOS_ADK_11120.exe,我花了 3 天时间才弄明白:

        • 从控制面板中删除任何版本的 Java,重新启动
        • 安装jdk-6u45-windows-i586.exe,重启
        • C:\ProgramData\Oracle\Java\javapath 中的java.exejavaw.exejavaws.exe 替换为来自C:\Program Files\Java\jre6\bin 的新Java 安装提供的可执行文件
        • 管理员身份执行 Epson 安装程序
        • 完成后恢复系统

        【讨论】:

          猜你喜欢
          • 2014-08-21
          • 2017-09-05
          • 2015-08-30
          • 1970-01-01
          • 2020-08-08
          • 1970-01-01
          • 2017-04-26
          • 2019-11-29
          • 2022-06-23
          相关资源
          最近更新 更多