【问题标题】:Sending commands from spa to thermal commands将命令从 spa 发送到 thermal 命令
【发布时间】:2023-01-18 02:14:10
【问题描述】:

我有一个水疗中心。我正在尝试打印到热敏打印机(标签和收据)。 不幸的是,我没有成功

我的热敏打印机是Xprinter XP-235B,我试过了
1- 构建一个本地迷你服务器(使用 .net 核心 - 使用 PrintDocument)与我的水疗中心进行通信,但是我觉得这个解决方案没有按预期工作(它需要进行大量校准)。我在 C# 中尝试过 zpl 命令,但看起来所有的库都过时了。 (或仅支持 ip 协议不支持 usb)
2- 使用 electron-pos-printer 构建 electron 应用程序,但它看起来已经过时并且开发人员已经忘记了它。

我已经达到了精神障碍。

有什么建议可以解决我的问题!?

【问题讨论】:

    标签: javascript angular printing single-page-application thermal-printer


    【解决方案1】:

    你有没有解决你的问题?我用 Electron 打印到热敏打印机。 您通常创建一个新窗口,然后打印该窗口。

    您可能不想使用远程方法,但您可以将其转换为:

    printElectron(内容:字符串,打印机名称:字符串,选项:printOptions):布尔值{

    let printWindow = new this.electronService.remote.BrowserWindow({ width: 350, height: 600 })
    
    printWindow.loadURL(contents)
      .then( e => {
    
        if (options.silent) {
          printWindow.hide();
        }
    
        if (!options) {
          options = {
            silent: true,
            printBackground: false,
            deviceName: printerName
          }
        }
    
        printWindow.webContents.print(
          options,
          (error, data) => {
            if (error) {
              // console.log('data', data)
              if (error == true)  {
                printWindow.close();
                printWindow = null;
                return false
              }
            }
            if (data) {
              printWindow.close();
              printWindow = null;
              return true
            }
          }
        )
    
        }).catch( err => {
          console.log('error', err)
          printWindow.close();
          printWindow = null;
          return false
        }
    )
    return false;
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-07
      • 2015-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多