我也在尝试用Ruby编写这个代码。所以用红宝石做一个例子就太棒了!
我不确定你在寻找哪些参数,ZPL,HTTP参数等。要使用HTTPPOST将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);
}