Javascript (爱普生tm-t20ii)使用qz打印打印多个html文件

Javascript (爱普生tm-t20ii)使用qz打印打印多个html文件,javascript,html,printing,Javascript,Html,Printing,我试着用QZprint和EPSON-TM-T20II打印文件夹中的多个html文件,但似乎没有效果 这是我使用的脚本示例: function printPages() { if (notReady()) { return; } qz.appendHTMLFile(getPath() + "misc/out-may-21.html"); qz.appendHTMLFile(getPath() + "misc/out-may-22.html"); while (!qz.isDone

我试着用QZprint和EPSON-TM-T20II打印文件夹中的多个html文件,但似乎没有效果

这是我使用的脚本示例:

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

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


while (!qz.isDoneAppending()) {
  qz.printHTML();
}
但它只会打印“out-may-22.html”文件。 -还有一个问题,当打印html文件时,它会打印html文件,然后再打印一个带有标记“”的文本文件

如此困惑,
谢谢。

更新:自QZ Tray 2.0以来,新的API支持一个无需混淆的回调

对于仍在使用QZ打印/QZ托盘1.9的用户,函数
QZ.appendHTMLFile(“…”)不同步,当前无法连续调用

相反,您必须等待调用
qzdoneadding()
,然后调用
printHTML()
,然后调用
qz.appendHTMLFile(“…”再次等等

<script>

   // Called automatically when the software has loaded
   function qzReady() {
      qz.findPrinter("epson");
   }

   // Called automatically when the software has finished searching for the printer
   function qzDoneFinding() {
       // append first file
       qz.appendHTMLFile("first.html");
   }

   var secondHasAppended= false;

   // Called automatically when a file is done appending
   function qzDoneAppending() {
       qz.print();
   }

   // Called automatically when document has been sent to the printer
   function qzDonePrinting() {
       if (!secondHasAppended) {
           qz.appendHTMLFile("second.html");
           secondHasAppended = true;
           // qzDoneAppending and qzDonePrinting will take care of the rest
       } else {
           alert("Done!");
       }
   }

</script>

//加载软件后自动调用
函数qzReady(){
qz.findPrinter(“爱普生”);
}
//软件完成打印机搜索后自动调用
函数qzDoneFinding(){
//附加第一个文件
appendHTMLFile(“first.html”);
}
var secondhasAdded=false;
//在文件追加完成时自动调用
函数qzdoneadding(){
qz.print();
}
//将文档发送到打印机时自动调用
函数qzDonePrinting(){
如果(!secondhasAdded){
appendHTMLFile(“second.html”);
秒=真;
//qzDoneAppending和qzDonePrinting将处理其余部分
}否则{
警报(“完成!”);
}
}

如果需要两个以上的文档,请将布尔值替换为计数器。

我使用QZTray 2.0.2,无法使其打印多页

它只打印第一页。换言之,它只打印它只能渲染1页的内容

我有3页HTML

当我将“scaleContent”设置为false时,它只打印第一页的一部分。当我将其设置为真时,它会按比例将所有页面打印成一页

所有我需要的是打印所有的页面一个接一个与缩放

最好的