edohernandez / jzebra

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

Send two PDF to printPDF() only last printed #239

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Generate an intermediate function to send two PDF documents to printPDF() 
function
2.Click on printPDF()
3.Only last document was sent to printer.

What is the expected output? What do you see instead?
I expected to print the two PDF documents. Only print last document sended to 
printer.

What version of the product are you using? On what operating system?
QZ Print Plugin 1.8.7
Windows 7 Ultimate x64

Please provide any additional information below.
I think it may be due window['qzDoneAppending'] has not finished append.
Do not know how it would be possible to fix.

Thanks.

Original issue reported on code.google.com by jesusdel...@gmail.com on 26 Mar 2015 at 10:07

Attachments:

GoogleCodeExporter commented 9 years ago
The sample provided is ready to reproduce this issue, copy it and PDF documents 
in the same path of the applet, open it and click on the red button.

Original comment by jesusdel...@gmail.com on 26 Mar 2015 at 10:47

GoogleCodeExporter commented 9 years ago
We don't yet support multiple adjacent appends with any of our 2d type 
functions (html, pdf, etc).  Instead, you'll have to wait for append, print the 
contents, wait for printing to finish, append again.

I understand this is cumbersome from a coding perspective to impliment.  Once 
QZ Tray is stable, we have plans to clean this up to allow the queuing of 2d 
documents as well as other queuing and multiple document/multiple printer 
enhancements.

Original comment by tres.fin...@gmail.com on 26 Mar 2015 at 12:52

GoogleCodeExporter commented 9 years ago
Thank you for your reply.
How can wait to complete first to process de second document, I tried this:

function Wait() 
{
   while (!qz.isDonePrinting() || !qz.isDoneAppending())
   {}
}

function printPDF() 
{
   printPDFDocument("one.pdf")
    Wait()
   printPDFDocument("two.pdf")
}

Did not work, any ideas?
Thanks.

Original comment by jesusdel...@gmail.com on 26 Mar 2015 at 1:01

GoogleCodeExporter commented 9 years ago
Please don't use while loops, that can deadlock your browser.

This should be your execution order:

> qz.appendPDF("/path/to/file1.pdf");

Wait for appending to finish:

> function qzDoneAppending() {
>      qz.printPS();
> }

Wait for printing to finish:

> function qzDonePrinting() {
>      qz.appendPDF("/path/to/file2.pdf");
> }

Before you try this... you'l need a counter to track which file you are on to 
not get into an infinite loop!

Original comment by tres.fin...@gmail.com on 26 Mar 2015 at 1:47

GoogleCodeExporter commented 9 years ago
The While was just a test to try to stop it, nothing serious.
I´ll try as you said.
Thanks again.

Original comment by jesusdel...@gmail.com on 26 Mar 2015 at 3:24

GoogleCodeExporter commented 9 years ago
We used while loops a few years ago, and for these PDF tasks specifically, they 
would cause sporatic deadlocks.

This is because there was no concept of "wait()" or "doEvents()" that gave time 
for the window.  Because of this, setTimeout() is going to yield much more 
stable results and that is a pretty good rule to follow with waiting in JS in 
general.

If I recall correctly, FF and Chrome could handle it a bit better, but I'd hate 
for a blocking action to yield poor results. :)

Original comment by tres.fin...@gmail.com on 26 Mar 2015 at 3:32