ilysander / jzebra

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

qz.print only run once in a loop #233

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
I found that if I call qz.append64 then qz.print in my loop,
it is not working expected. there is only one print request sent to the printer 
queue by qz code.

if I add an alert at the end of qz.print(), it works fine.

this seems to be a bug ?

I just simply change the sample.html to reproduce the problem.

function print64Loop3() {
        if (notReady()) { return; }

        // Send base64 encoded characters/raw commands to qz using "append64"
        // This will automatically convert provided base64 encoded text into 
        // text/ascii/bytes, etc.  This example is for EPL and contains an 
        // embedded image.  Please adapt to your printer language
            for(i=1;i<=3;i++)
        {
                qz.append64('Ck4KcTYwOQpRMjAzLDI2CkI1LDI2LDAsMUEsMyw3LDE1MixCLCIxMjM0IgpBMzEwLDI2LDAsMywx');

                // Tell the apple to print.
                //myPause(5000); THE PRINT REQUESTS COULD BE SEEN BUT PAGE INFO INCORRECT.
                qz.print();
                alert("print done "+i);
        }
    }

Original issue reported on code.google.com by commute...@gmail.com on 25 Jan 2015 at 6:03

GoogleCodeExporter commented 8 years ago
Not a bug.  Use the callback qzDonePrinting() as the call is asynchronous and 
then use that to make subsequent calls.  What you are describing would normally 
block the GUI.

We eventually want to queue these requests up but that is harder to manage as 
they tend to run off without a good way to track them.  That feature is shelved 
until after we finish qz-tray.

Original comment by tres.fin...@gmail.com on 27 Jan 2015 at 3:16

GoogleCodeExporter commented 8 years ago
thanks for your reply. but I don't actually get what you mean.
appreciate that if you can give me a simple sample code to achieve my goal.
--simply to print 3 copies of my doc. 

Original comment by commute...@gmail.com on 28 Jan 2015 at 2:07

GoogleCodeExporter commented 8 years ago
If you want to append 3 copies, why don't you just append64 3 times? You don't 
need to call print each time you append.  :)

Original comment by tres.fin...@gmail.com on 28 Jan 2015 at 9:53

GoogleCodeExporter commented 8 years ago
thanks for the hints.
actually in my case, I have 3 rows data returned from jquery. the data are pdf 
stream encoded with base64. 
when I simply use append64 to append 3 rows, I see only 1 page in my adobe pdf 
reader(my printer allows me to spool the print request to a file as well), 
though I can see the pdf file size is 3 times comparing with 1 row data.
however 3 copies were printed out.
I think that's a problem for the pdf reader if I simply append 3 rows of data.

but it works fine for me after your hints. thank you very much!

Original comment by commute...@gmail.com on 29 Jan 2015 at 7:50