从信息亭打印东西时我应该使用什么语言

What language I should use when printing something from a kiosk

所以我现在参与了一个项目,我的顾问让我创建一个基于 Web 的信息亭。是的,我在考虑 html、javascript 等。但我的问题是在链接 POS 时使用什么语言(标记或不标记) 打印机到基于网络的(信息亭)。我的想法是让客户点击他或她想要订购的东西,然后在客户完成其请求时点击。它通过 POS 打印机打印出请求

您可以在 JavaScript 中完成。爱普生其实有一个Epson ePOS SDK for JavaScript.

我在网上找到了这个示例代码。无法测试它,因为我现在附近没有 Epson POS 打印机。

var printer = null;
var ePosDev = null;

function InitMyPrinter()
{ 
console.log("Init Printer");

var printerPort = 8008;
var printerAddress= "192.168.198.168"; 
if(isSSL)
{
printerPort = 8043;
} 
ePosDev = new epson.ePOSDevice();
ePosDev.connect(printerAddress, printerPort, cbConnect);
}
//Printing
function cbConnect(data) {
if(data == 'OK' || data == 'SSL_CONNECT_OK') {
ePosDev.createDevice('local_printer', ePosDev.DEVICE_TYPE_PRINTER,
{'crypto':false, 'buffer':false}, cbCreateDevice_printer);
} else {
console.log(data);
}
}

function cbCreateDevice_printer(devobj, retcode) {
if( retcode == 'OK' ) {
printer = devobj;
printer.timeout = 60000;
printer.onreceive = function (res) { //alert(res.success);
console.log("Printer Object Created");

};
printer.oncoveropen = function () { //alert('coveropen');
console.log("Printer Cover Open");

}; 
} else { 
console.log(retcode);
isRegPrintConnected = false;
}
}

function print(salePrintObj) {
debugger;
if(isRegPrintConnected == false
|| printer==null)
{
return ;
}
console.log("Printing Started");


printer.addLayout(printer.LAYOUT_RECEIPT, 800, 0, 0, 0, 35, 0);
printer.addTextAlign(printer.ALIGN_CENTER);
printer.addTextSmooth(true);
printer.addText('\n');
printer.addText('\n');

printer.addTextDouble(true, true);
printer.addText(CompanyName + '\n');

printer.addTextDouble(false, false);
printer.addText(CompanyHeader + '\n');
printer.addText('\n');

printer.addTextAlign(printer.ALIGN_LEFT);
printer.addText('DATE: '+currentDate+'\t\t');

printer.addTextAlign(printer.ALIGN_RIGHT);
printer.addText('TIME: '+currentTime+'\n');

printer.addTextAlign(printer.ALIGN_LEFT);

printer.addTextAlign(printer.ALIGN_RIGHT);
printer.addText('REGISTER: '+RegisterName+'\n');
printer.addTextAlign(printer.ALIGN_LEFT);
printer.addText('SALE # '+SaleNumber+'\n');

printer.addTextAlign(printer.ALIGN_CENTER);
printer.addTextStyle(false, false, true, printer.COLOR_1);
printer.addTextStyle(false, false, false, printer.COLOR_1);
printer.addTextDouble(false, true);
printer.addText('* SALE RECEIPT *\n');
printer.addTextDouble(false, false);
....
....
.... 

}

希望对您有所帮助。