简体   繁体   English

使用 tcp 网络应用程序打印到 pos 热敏打印机

[英]Print to pos thermal printer using tcp web-application

I have a task to create a web application on javascript/typescript that could print to the pos printer directly using TCP or some other protocol.我的任务是在 javascript/typescript 上创建一个 web 应用程序,该应用程序可以使用 TCP 或其他一些协议直接打印到 pos 打印机。 Everything has to happen on the customer's device not using the server.一切都必须在不使用服务器的客户设备上进行。 The customer should be able to print in his local network客户应该能够在他的本地网络中打印

Testing on EPSON TM-T20III I tried using WebSocket for that but it sends its header to the printer在 EPSON TM-T20III 上进行测试我尝试使用 WebSocket 进行测试,但它会将 header 发送到打印机

let ws = new WebSocket("ws://192.168.1.171:9100/");
    console.log(ws);ws.onopen = function (e) {
        console.log(e);
        ws.send('test test test');};

    ws.onclose = function(e) {
        console.log("Done");};
    ws.onerror = function(e) {
        console.log("Error");};
}

I get this from the printer:我从打印机得到这个:

GET / HTTP/1.1
Host: 192.168.1.171:9100
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Macintosh: Intel Mac OS
X 10 15 7) ApplewebKit/537.35 (KHTML, like Geck
o) Chrome/104.0.0.0 Safari/537.36
Upgrade: websocket
Origin: http://localhost:4300
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate
Accept-Language:en-US,en;q=0.9,lt;q=0.8,ru;q=0.
7
Sec-WebSocket-Key:YTtnLHd6T+4YEEzlyro16Q==
Sec-WebSocket-Extensions: permessage-deflate; cl
ent max _window _bits
GET / HTTP/1.
Host: 192.168.1.171:9100
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS
X 10 15 7) AppleWebKit/537.36 (KHTML, like Geck
0) Chrome/104.0.0.0 Safari/537.36
Upgrade: websocket
Origin: http://localhost: 4300
Sec-WebSocket-Version:13
Accept-Encoding: gzip, deflate
Accept-Language:en-US,en;q=0.9,1t;0=0.8,ru;q=0.
Sec-WebSocket-Key:4840Pq0V1LHpgLeZZadhEw==
Sec-WebSocket-Extensions: permessage-deflate; cl
ent max _window_bits

tried using socket.net尝试使用 socket.net

const Net = require("net");

let name = this.host + ":" + this.port;
    let printer = Net.connect(
        {
            // host: this.host,
            host: '192.168.1.171',
            port: this.port || 9100,
            timeout: this.timeout || 3000
        },

    );
    
function execute (resolve) {
    printer.write('buffer', null, function () {
        resolve("Data sent to printer: " + name);
        printer.destroy();
    });
}
execute();

But then I need to start a Node server on the client's device which is too complicated for the client.但是我需要在客户端的设备上启动一个节点服务器,这对客户端来说太复杂了。

I'm looking for other options, but can't find anything.我正在寻找其他选择,但找不到任何东西。 A lot of things are blocked for security reasons.出于安全原因,很多东西都被阻止了。 Can anybody help?有人可以帮忙吗?

You Should use the javascrpt SDK https://download.epson-biz.com/modules/pos/index.php?page=soft&scat=57 .您应该使用 javascrpt SDK https://download.epson-biz.com/modules/pos/index.php?page=soft&s .

I'm currently struggling with some CORS stuff.我目前正在努力解决一些 CORS 的问题。 I'm not getting the access-control-allow-origin-header when connecting to TM-T20IIIL (with TM-T20II I have it working)连接到 TM-T20IIIL 时我没有得到 access-control-allow-origin-header(使用 TM-T20II 我可以正常工作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Web 应用程序的拖车打印机中打印 pos 收据 - print pos receipt in tow printer in web application 如何使用基于 ASP.NET Web 的应用程序使用 jicai q2 POS 热敏打印机 (Sunmi V1)? - How to use jicai q2 POS Thermal Printer (Sunmi V1) using asp.net web based application? 使用 JavaScript 通过 ESC/POS 将图像打印命令发送到以太网上的热敏打印机 - Send image print command via ESC/POS using JavaScript to thermal printer on ethernet 是否可以在热敏打印机上打印网页内容? - Is it possible to print web content on thermal printer? 如何从android web浏览器打印到蓝牙热敏打印机? - How to print from android web browser to Bluetooth thermal printer? 在热敏打印机上进入ESC / POS模式 - Enter ESC/POS Mode on Thermal Printer 在按钮上单击使用 JavaScript、angular 或 Node JS 在热敏打印机上打印 - On button click print on Thermal Printer using JavaScript, angular or Node JS 如何使用 javascript 直接打印到网络热敏打印机? - How to directly print to network thermal printer using javascript? Javascript-在客户端的热敏打印机上打印(无小程序) - Javascript - Print on thermal printer on client (No applet) Android EPSON热点打印来自网页视图的数据点击?如果找不到打印机? - Android EPSON thermal Print data from web-view on click?If Printer Not Found?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM