gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 12:22:52 25 4
gpt4 key购买 nike

我尝试使用 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没有令人困惑的回调。

对于仍在使用 QZ Print/QZ Tray 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>

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

关于javascript - (epson tm-t20ii) 使用 qz-print 打印多个 html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30434282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com