(epson tm-t20ii) 使用 qz-print 打印多个 html 文件

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

我尝试使用 qz-print 和 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 支持 data block which supports multiple HTML files 而不会混淆回调。

还在使用QZPrint/QZTray 1.9的,函数qz.appendHTMLFile("...");不是同步的,目前不能连续调用

相反,您必须等到调用 qzDoneAppending(),然后调用 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>

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

我用的是QZTray 2.0.2,无法打印多页。

它只打印第一页。换句话说,它只打印它只能呈现一页的内容。

我有 3 页 HTML。

当我将 "scaleContent" 设置为 false 时,它​​只打印第一页的一部分。当我将其设置为 true 时,它​​会通过缩放将所有页面打印成一页。

我只需要通过缩放将所有页面打印出来。

最佳