The Mechanic The Mechanic -5 years ago 254
Javascript Question

(epson tm-t20ii) print multiple html files with qz-print

I tried to print multiple html files in folder with qz-print and EPSON - TM-T20II, but seem no work.

This is an example of script that i used:

function printPages() {
if (notReady()) {

qz.appendHTMLFile(getPath() + "misc/out-may-21.html");
qz.appendHTMLFile(getPath() + "misc/out-may-22.html");

while (!qz.isDoneAppending()) {

but it will only print "out-may-22.html" file.
- And one more problem, when printing html file, it print html file, then print one more text file with tag "".

So confused,

Answer Source

Update: Since QZ Tray 2.0, the new API supports a data block which supports multiple HTML files without confusing callbacks.

For those still using QZ Print/QZ Tray 1.9, the function qz.appendHTMLFile("..."); is not synchronous and cannot currently be called in succession.

Instead, you'll have to wait until qzDoneAppending() is called, then call printHTML(), then call qz.appendHTMLFile("..."); again, etc.


   // Called automatically when the software has loaded
   function qzReady() {

   // Called automatically when the software has finished searching for the printer
   function qzDoneFinding() {
       // append first file

   var secondHasAppended= false;

   // Called automatically when a file is done appending
   function qzDoneAppending() {

   // Called automatically when document has been sent to the printer
   function qzDonePrinting() {
       if (!secondHasAppended) {
           secondHasAppended = true;
           // qzDoneAppending and qzDonePrinting will take care of the rest
       } else {


If you require more than two documents, replace the boolean with a counter.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download