Class: PrintHandler

PrintHandler()

a class to handle printing.
There are two options:
(1) if you are adding lines to be printed one-by-one, then you can instantiate a PrintHandler object and use the addLine and submitPrint methods.
(2) if you already have your lines that you want printed stored in an array, then you can simply use the static method PrintHandler.printLines, and it will handle all the printing for you

Constructor

new PrintHandler()

Author:
  • Michael Crockett
Source:

Methods

addLine(text)

store a line to be submitted with submitPrint

Parameters:
Name Type Description
text string

line of text, which must end in "\n"

Source:

reset()

clear out any stored lines in this print handler

Source:

setLines(lines)

override currently stored lines

Parameters:
Name Type Description
lines Array.<String>

an array of lines to be printed, each ending with "\n"

Source:

submitPrint(log)

submit all stored lines to the receipt printer

Parameters:
Name Type Default Description
log false

if true, log each printed line to the js console

Source:

(static) printLines(lines, log)

static method to print a given set of lines without instantiating a PrintHandler object.

Parameters:
Name Type Default Description
lines Array.<string>

each line to print must end in "\n"

log boolean false

if true, log each printed line to the js console

Source: