Printing HTML and PostScript on the same receipt using jZebra

2k views Asked by At

Based on the tutorial here, I can separately print HTML and PostScript to an Epson T88V receipt printer using jZebra. I would like to use both printing methods on the same label - HTML for text & layout, PostScript for barcode rendering. Unfortunately I can only get one or the other to print, not both on the same label.

Here is the js which is contained in a print button click event:

//   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();

If I run the code as-is, only the text is printed. If I comment out the text printing lines, the barcode is printed.

I've tried to use applet.clear(); after the first print and tried switching the order of printing but nothing changes. Is there a way to print a barcode and text in one go?

1

There are 1 answers

1
Tres Finocchiaro On

Yes what you request is possible, but you should not be using HTML and ESC/P commands interchangeably. Please refer to the ESC/P programmer's manual supplied by your printer manufacturer for printing text.

Here is a sample from ESCPCommands, taken from the jZebra wiki along with a quick explanation.

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.

Credit for the code snippet goes to Bahadir from the jZebra mailing list.

-Tres