Last active
January 29, 2025 10:27
-
-
Save kilbot/b47b1f80e2bfeb7d75e4e99a97a40f73 to your computer and use it in GitHub Desktop.
Test epos-print via network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<title>ePOS-Print</title> | |
<script type="text/javascript"> | |
// URL of ePOS-Print supported TM printer (Version 4.1 or later) | |
var url = 'http://10.0.0.201/cgi-bin/epos/service.cgi'; | |
// URL of ePOS-Print supported TM printer | |
// var url = 'http://10.0.0.201/cgi-bin/epos/service.cgi?devid=local_printer&timeout=10000'; | |
function button1_Click() { | |
// Create print document (Version 4.1 or later) | |
var req = | |
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' + | |
'<s:Header>' + | |
'<parameter xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">' + | |
'<devid>local_printer</devid>' + | |
'<timeout>10000</timeout>' + | |
'<printjobid>ABC123</printjobid>' + | |
'</parameter>' + | |
'</s:Header>' + | |
'<s:Body>' + | |
'<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">' + | |
'<pulse drawer="drawer_1" time="pulse_100" />' + | |
'<text lang="en" smooth="true">Intelligent Printer </text>' + | |
'<barcode type="ean13" width="2" height="48">201234567890</barcode>' + | |
'<feed unit="24"/>' + | |
'<image width="8" height="48">8PDw8A8PDw/w8PDwDw8PD/Dw8PAPDw8P8PDw8A8PDw/w8PDwDw8PD/Dw8PAPDw8P</image>' + | |
'<cut/>' + | |
'</epos-print>' + | |
'</s:Body>' + | |
'</s:Envelope>'; | |
// Send print document | |
var xhr = new XMLHttpRequest(); | |
xhr.open('POST', url, true); | |
xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf-8'); | |
xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT'); | |
xhr.setRequestHeader('SOAPAction', '""'); | |
xhr.onreadystatechange = function () { | |
// Receive response document | |
if (xhr.readyState == 4) { | |
// Parse response document | |
if (xhr.status == 200) { | |
// alert(xhr.responseXML.getElementsByTagName('response')[0].getAttribute('success')); | |
} | |
else { | |
alert('Network error occured.'); | |
} | |
} | |
}; | |
xhr.send(req); | |
} | |
// | |
</script> | |
</head> | |
<body> | |
<div style="text-align: center;"> | |
<button onclick="button1_Click()">Print</button> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment