vikashsingh009 / jzebra

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

jZebra qz-print fails for bigger task (>50) #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I have seen quite a few raised issue with the same problem but with no 
resolution yet. I have a simple system setup for barcode printing based on 
[jZebra qz-print][1] over my browser which works great. 

The system functions well when the number of barcodes to be printed is on a 
lower side (<50), however, with the increase in count it just behaves stupidly, 
most of the time it prints lesser barcodes, sometimes more and sometimes 
proper. I am not able to track the problem because of this random behavior.

Please find a small section of my code, just to understand:

    //just part of a huge code
     function printBarcodes() {
        var   totalBarcodes = 0;
        var subTotal = 0;
        var print = print_array;
        var date_string = "some_date_string";
        qz.append("N\n");
        qz.append("q1218\n");
        qz.append("Q303,26\n");
        qz.append('TDdd me y4\n'); 

        $.each( print, function( key, value ) {
            pB(key,value,date_string); // function which organizes the barcodes
        });
        if(odd){
         qz.append('\nP1,1\n');
         qz.append('END');
        // alert("appending odd");
        }else{
        //  alert("not appending");
        }
         // Mark the end of a label, in this case  P1 plus a newline character
         // qz-printknows to look for this and treat this as the end of a "page"
         // for better control of larger spooled jobs (i.e. 50+ labels)
         qz.setEndOfDocument("END");

         // The amount of labels to spool to the printer at a time. When
         // qz-print counts this many `EndOfDocument`'s, a new print job will 
         // automatically be spooled to the printer and counting will start
         // over.
         qz.setDocumentsPerSpool("10");      
         qz.print();
    //   monitorPrinting(qz);
    }

Based on a few suggestions available online I have set documents per spool to 
be 10 (I have also tried 1 just to split it even further), however, this hardly 
seems to solve the problem.

Any help here would be really appreciated. Thanks.

Original issue reported on code.google.com by chintanp...@gmail.com on 7 Feb 2015 at 9:31

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/jzebra/wiki/TutorialWebApplet#Advanced_Print_Spooling

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 1:05

GoogleCodeExporter commented 9 years ago
I request you to please read the question properly. Please read the last 
paragraph and last 3 lines of code. I have already done that and I am still 
facing the same problem.

Original comment by chintanp...@gmail.com on 7 Feb 2015 at 1:09

GoogleCodeExporter commented 9 years ago
I'm not sure calling behavior "stupid" is the right way to approach any bug 
report.

Is "END" a valid EPL command?  Usually `\nP1,`\n` is what programmers use to 
mark the end of hte document.

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 1:09

GoogleCodeExporter commented 9 years ago
Thank you for your reply. I guess, that could be the reason. I will just 
re-test it and update the answer. Thanks a ton again.  

Original comment by chintanp...@gmail.com on 7 Feb 2015 at 1:13

GoogleCodeExporter commented 9 years ago
> I request you to please read the question properly.

There are thousands of PCs around the world using this functionality without 
issues.  Perhaps instead you should exercise some manners when seeking free 
help.

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 1:15

GoogleCodeExporter commented 9 years ago
I'd like to also add that the issue tracker isn't the place for support 
requests.  You'll reach more people here:

http://qzindustries.com/support

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 1:18

GoogleCodeExporter commented 9 years ago
I am sorry, I had no intention of being rude. Really appreciate your answer. 
Thanks. 

Original comment by chintanp...@gmail.com on 7 Feb 2015 at 1:19

GoogleCodeExporter commented 9 years ago
I am sorry for dropping in a comment again. I still have the problem, only if 
you think it is appropriate to comment here, I will add the problem (/doubt) 
part. Please ignore if you think it is not appropriate. Thanks again for the 
polite answers.

Original comment by chintanp...@gmail.com on 7 Feb 2015 at 1:48

GoogleCodeExporter commented 9 years ago
Is your jQuery $.each a synchronous function?

If you want to avoid going through paper, you could try printing to a file and 
seeing if something is out of order.

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 2:03

GoogleCodeExporter commented 9 years ago
Thanks again for the reply.

Yes, almost all jQuery functions are synchronous. I have also tried to put a 
confirm box before printing (just to make sure printing is only taking place 
after the process).Also, looked up in the mean time just for confirmation over 
here: 
http://stackoverflow.com/questions/7371942/is-jquery-each-function-synchronous

Well, you are absolutely right, it is better to test using a text file instead 
( Will start the same soon.  )

However, just for reference, there are 2 problems I am facing:

1. My print jobs are usually huge ( please refer to the entire javascript code 
attached if possible), the print array is processed by PHP and then given to 
javascript for printing. Now there are multiple barcodes which needs to be 
printed as a set and hence according to the definition in EPL I have to use a 
different print command as follows:

qz.append('\nP'+set+',1\n'); // line 93 of the attached file

Since I am already using this command for printing I guess I can't use:

qz.setEndOfDocument("P1\n");

Since this would result in an additional print command (or it would skip the 
above mentioned end of documents). (Please correct me if I am wrong here).

2. This is kind of strange. I powered off the printer to check out the print 
jobs and to my surprise every print command for the same task issued "different 
sizes" of print jobs. I kind of don't belong to this background, however, I was 
assuming that atleast the sum of (sizes of) all the print jobs should be the 
same, however, that's not happening

Apologies for stretching the comment. I am sure I am missing some small concept 
here or there. Would be really helpful if you could point me in the right 
direction.

Thanks.

Original comment by chintanp...@gmail.com on 7 Feb 2015 at 2:38

Attachments:

GoogleCodeExporter commented 9 years ago
Sounds like you could really benefit from a wildcard enhancement in the 
setEndOfDocument(...) function. 

You could try an extra newline and do something like ',1,\n\n' perhaps?

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 7:50

GoogleCodeExporter commented 9 years ago
If there is an option for wild card then I can just do something like this?

qz.setEndOfDocument('\nP%',1\n'); // % as an wild card

Is this possible? 

Original comment by chintanp...@gmail.com on 7 Feb 2015 at 8:21

GoogleCodeExporter commented 9 years ago
No, that is not currently available.  That would be an enhancement to current 
functionality.

Do you suspect the extra newline trick to suffice for now?

Original comment by tres.fin...@gmail.com on 7 Feb 2015 at 10:56

GoogleCodeExporter commented 9 years ago
Just got an opportunity to test it again. However, still facing the same issue. 
When the barcodes are more than 60 or 70 the size of the print jobs are 
changing. In my case I had a task to print 161 barcodes with documents per 
spool 20. It generates 3 jobs in the printing queue of ~"5kb,9kb,9kb" or 
sometimes ~"9kb,9kb,9kb". I verified it for tasks less than 50 barcodes and the 
size was fixed in the all the runs.

Any clue of why this could happen?

Thanks again for all the replies.

Original comment by chintanp...@gmail.com on 9 Feb 2015 at 6:00

GoogleCodeExporter commented 9 years ago
I figured out the problem. There was some global javascript variable which was 
causing the problem. 

Extremely sorry for wasting your time and raising an invalid issue.

However, just for reference, setting end of document to a text "END" (or 
anything else), works pretty much the same way as one you suggested (probably 
could be of help to someone).

Again, extremely sorry and thanks for your support.

Original comment by chintanp...@gmail.com on 9 Feb 2015 at 9:15

GoogleCodeExporter commented 9 years ago
> "There was some global javascript variable which was causing the problem."

Those are the toughest yo troubleshoot.  Glad you got I working. 

Original comment by tres.fin...@gmail.com on 9 Feb 2015 at 12:05