Closed GoogleCodeExporter closed 8 years ago
[deleted comment]
You can control the spooling of documents which may alleviate problems
encountered when printing multiple subsequent items.
Generally, the buffer in a printer is only able to store a limited amount of
information. Depending on the information you are sending, you may be
overflowing the print buffer.
You can send these one-by-one by forcing Windows to spool each document before
printing the next. This feature has fixed the same problem for others,
although they were usually reporting larger batches than 6.
http://code.google.com/p/jzebra/wiki/TutorialWebApplet#Advanced_Print_Spooling
Let me know if that helps.
Original comment by tres.fin...@gmail.com
on 12 Nov 2012 at 11:33
In order to implement this properly, you must know how each label ends (i.e.
P1\n) then set how many documents should spool before sending a new print job,
which in your case should probably be 1.
function print() {
document.jZebra.setEndOfDocument("P1\n"); // Change this to how each label ends.
document.jzebra.setDocumentsPerSpool("1");
document.jzebra.print();
}
-Tres
Original comment by tres.fin...@gmail.com
on 12 Nov 2012 at 11:36
Here is my original JS method to print the labels.
//handle user action of clicking the print button
function print() {
var applet = document.jzebra;
var labelArray = new Array();
<c:forEach var="label" items="${shippingLabels}" varStatus="status">
labelArray[${status.index}] = "${label}";
</c:forEach>
if(applet != null) {
applet.setEndOfDocument("^XZ^XZ"); // Change this to how each label ends.
applet.setDocumentsPerSpool("1");
var len = labelArray.length;
for(var i = 0; i < len; i++) {
if( i in labelArray) {
applet.append(labelArray[i]);
applet.print();
monitorPrinting();
}
}
document.getElementById('shippingTrackingNumber').focus();
}
else {
alert("print - Applet not loaded!");
}
}
Now based on your suggestions I do believe that I have implemented this
incorrectly from the get go. Here is the corrected JS Method, including your
suggestions:
//handle user action of clicking the print button
function print() {
var applet = document.jzebra;
var labelArray = new Array();
<c:forEach var="label" items="${shippingLabels}" varStatus="status">
labelArray[${status.index}] = "${label}";
</c:forEach>
if(applet != null) {
var len = labelArray.length;
for(var i = 0; i < len; i++) {
if( i in labelArray) {
applet.append(labelArray[i]);
}
}
applet.setEndOfDocument("^XZ^XZ"); // Change this to how each label ends.
applet.setDocumentsPerSpool("1");
applet.print();
monitorPrinting();
document.getElementById('shippingTrackingNumber').focus();
}
else {
alert("print - Applet not loaded!");
}
}
As you can see the big change was to load the applet up with all the labels
upfront. Then, print them. At the moment it would appear that I am able to
get all the labels printed, well see how it goes in production.
Thanks for such a quick turn around on this question.
Original comment by boyd4...@gmail.com
on 13 Nov 2012 at 4:05
You got it.
The only problem with your previous logic is you weren't checking to see if the
print job was done before printing the next one.
This is assumed by calling "monitorPrinting()", however, there's no nice way to
pause or "wait" in JavaScript, so it turns into a while loop, which will
deadlock the browser, or a setTimeout() callback game, which is very hard to
keep track of.
Also, there's some new functions you may benefit from by studying loading.html,
which allows the done printing to be triggered by the applet rather than the
recursive monitorPrinting() function.
Closing bug and marking as invalid. Feel free to add additional comments if
needed. :)
-Tres
Original comment by tres.fin...@gmail.com
on 13 Nov 2012 at 5:22
Original issue reported on code.google.com by
boyd4...@gmail.com
on 12 Nov 2012 at 8:55