gpt4 book ai didi

java - 使用 jZebra 在同一张收据上打印 HTML 和 PostScript

转载 作者:太空宇宙 更新时间:2023-11-04 07:26:22 26 4
gpt4 key购买 nike

基于教程 here ,我可以使用 jZebra 将 HTML 和 PostScript 分别打印到 Epson T88V 收据打印机。我想在同一个标​​签上使用两种打印方法 - HTML 用于文本和布局,PostScript 用于条形码渲染。不幸的是,我只能打印其中之一,而不能将两者打印在同一个标​​签上。

这是打印按钮点击事件中包含的js:

//   Text print
applet.appendHTML('<html><table face="monospace" border="1px"><tr height="6cm">' +
'<td valign="top">' + [some var value] + '</td>' +
'<td valign="top">' + [some other var value] + '</td>' +
'</tr></table></html>');
applet.printHTML();

// Barcode print
applet.append("\x1D\x77\x02\x1D\x6B\x49\x11\x7B\x41\x4C000288496\x508149");
applet.print();

如果我按原样运行代码,则仅打印文本。如果我注释掉文本打印行,则会打印条形码。

我尝试在第一次打印后使用 applet.clear(); 并尝试切换打印顺序,但没有任何变化。有没有办法一次性打印条形码和文本?

最佳答案

是的,您的请求是可能的,但您不应该交替使用 HTML 和 ESC/P 命令。有关打印文本的信息,请参阅打印机制造商提供的 ESC/P 编程器手册。

这是来自 ESCPCommands 的示例,摘自 jZebra wiki 以及快速解释。

applet.append("\x1B\x40"); // 1
applet.append("\x1B\x21\x08"); // 2
applet.append(" International \r\n");
applet.append(" Company \r\n");
applet.append("\x1B\x21\x01"); // 3
applet.append(" ************************************************** \r\n");
applet.append("Info: 42972\r\n");
applet.append("Info: Kommm\r\n");
applet.append("Datum: 14:00 01/02\r\n");
applet.append(" -------------------------------------------------- \r\n");
applet.append("Info: 42972\r\n");
applet.append("Info: Kommm\r\n");
applet.append("Datum: 14:00 01/02\r\n");
applet.append(" -------------------------------------------------- \r\n");
applet.append(" \r\n");
applet.append(" \r\n");
applet.append(" \r\n");
applet.append(" \r\n");
applet.append("\x1D\x56\x41"); // 4
applet.append("\x1B\x40"); // 5
  • Here it starts with initation command ESC @ (hex: \x1B\x40) Set style to bold with font A ( bit 0 (indicates font 0) + bit 8 (indicates emphasize) = 8, ESC ! 8, hex: \x1B\x08)
  • Set style to font B, without any style (bit 1 = 1, ESC ! 1, hex: \x1B\x01)
  • Cut command
  • Make sure to reset printer if any other program is using this one, just in case it won't reset it.

代码片段的功劳来自 jZebra 邮件列表中的 Bahadir。

-特雷斯

关于java - 使用 jZebra 在同一张收据上打印 HTML 和 PostScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18469979/

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