Search…
PrinterManager

Overview

PrinterManager is the class responsible for enabling printing on Cielo machines and it uses the singleton pattern to guarantee a unique instance of PrinterManager.

Atributes

The attributes will be inserted into the hashMap and will be used at the time of printing

Used in alignment - KEY_ALIGN

Name
Description
VAL_ALIGN_CENTER
Align to center
VAL_ALIGN_LEFT
Align to left
VAL_ALIGN_RIGHT
Align to right

Other features

Name
Description
KEY_TEXT_SIZE
Text size, must be an integer value
KEY_TYPEFACE
Text font, must be an integer between 0 and 8, where each value is a different font
KEY_MARGIN_LEFT
Left margin, must be an integer value
KEY_MARGIN_RIGHT
Right margin, must be an integer value
KEY_MARGIN_TOP
Top margin, must be an integer value
KEY_MARGIN_BOTTOM
Bottom margin, must be an integer value
KEY_LINE_SPACE
Spacing between consecutive lines, must be an integer value
KEY_WEIGHT
Used when printing multiple columns, to choose the weight of each column, must be an integer value

Methods

Name
Description
getInstance()
Creates a new instance or returns the instance previously created.
printText(String textToPrint, Map<String, Integer> printerAttributes)
printText(String textToPrint, Map<String, Integer> printerAttributes, PrinterListener printerListener)
Prints the text received in the textToPrint parameter.
printerAttributes will have the attributes of the print.
printerListener will receive the PrinterListener interface methods

Usage

Code Example
1
HashMap<String, Integer> printerAttributes = new HashMap<>();
2
3
printerAttributes.put(PrinterAttributes.KEY_ALIGN, PrinterAttributes.VAL_ALIGN_CENTER);
4
printerAttributes.put(PrinterAttributes.KEY_TYPEFACE, 1);
5
printerAttributes.put(PrinterAttributes.KEY_TEXT_SIZE, 20);
6
7
String textToPrint = "TEXT TO PRINT";
8
PrinterManager.getInstance()
9
.printText(textToPrint, printerAttributes);
Copied!
Last modified 2yr ago