vikashsingh009 / jzebra

Automatically exported from code.google.com/p/jzebra
0 stars 0 forks source link

Not All Labels are being printed #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Using UPS as the label generator, have it create 11 labels
2. When the page loads, the Print() function on the jsp will have the array 
populated via JSTL with 11 labels when the page renders.
3. Select print button

What is the expected output? What do you see instead?

Expected to see all labels printed, of the 11 only 9 showed up the first time, 
selecting back and then navigating to the print page, selecting print labels 
got 10.

What version of the product are you using? On what operating system?
Using 1.4.5 running on RedHat 5.x

Please provide any additional information below.
Seeing no errors via FireBug.  Have tried on IE 9, Chrome and FF and same 
results.  It always seems to occur when the label count is > 6.

Original issue reported on code.google.com by boyd4...@gmail.com on 12 Nov 2012 at 8:55

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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