我也试图用Ruby编写代码。所以在红宝石中的一个例子就是精彩!
答案 0 :(得分:1)
我不确定您要查找的参数,ZPL,HTTP参数等。要使用HTTP POST将一个类似ZPL中的目录列表打印到Zebra打印机,它应具有以下格式:登记/>
POST / pstprnt HTTP / 1.1 <CR><LF>
内容长度:9 <CR><LF><CR><LF>
^ XA ^ WD ^ XZ
我没有ruby示例,但在javascript中它看起来像这样:
function print_this(zpl, ip_addr)
{
var output = document.getElementById("output");
var url = "http://"+ip_addr+"/pstprnt HTTP/1.1";
var method = "POST";
var async = true;
var request = new XMLHttpRequest();
request.onload = function () {
var status = request.status; // HTTP response status, e.g., 200 for "200 OK"
var data = request.responseText; // Returned data, e.g., an HTML document.
output.innerHTML = "Status: " + status + "<br>" + data;
}
request.open(method, url, async);
request.setRequestHeader("Content-Length", zpl.length);
// Actually sends the request to the server.
request.send(zpl);
}