[英]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.