Epson thermal javascript printer

I am trying to use the Epson TM-T20II (thermal printer) through a web page. I made the necessary configuration, and the printer works fine on my network using this software. So I downloaded the SDK to print JS epos and tried to run this sample code:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
    <title>TITLE</title>
    <script type="text/javascript" src="../ePOS-Print_SDK/ePOS-Print_SDK_150729E/JavaScript/epos-print-5.0.0.js"></script>
    <script type="text/javascript">
         function buildMessage() {
             //Create an ePOS-Print Builder object
             var builder = new epson.ePOSBuilder();
             //Create a print document
             builder.addTextLang('en')
             builder.addTextSmooth(true);
             builder.addTextFont(builder.FONT_A);
             builder.addTextSize(3, 3);
             builder.addText('Hello,\tWorld!\n');
             builder.addCut(builder.CUT_FEED);
             //Acquire the print document
             var request = builder.toString();
             var address = 'http://192.168.1.65/cgi-bin/epos/service.cgi?devid=99&timeout=1000';
             //Create an ePOS-Print object
             var epos = new epson.ePOSPrint(address);
             epos.onreceive = function (res) {
             //When the printing is not successful, display a message
             if (!res.success) {
                alert('A print error occurred');
                }
             }
             //Send the print document
             epos.send(request);
         }
    </script>
    </head>
    <body>
     <button onclick='buildMessage()'>Run</button>
    </body>
</html>

For the devid parameter, I tried "local_printer", which is the name of the device, then I saw in the configuration panel that the printer ID is 99. However, it does not work, I got the 405th method that does not resolve the status code in the cgi request .

Any tips? Thanks in advance.

EDIT:

, , CORS. , , "Access-Control-Allow-Origin". , ?

+4
1

, CORS, , Chrome -. chrome CORS:

chromium-browser --disable-web-security

https://www.chromium.org/developers/how-tos/run-chromium-with-flags

0

Source: https://habr.com/ru/post/1626379/


All Articles