The PrinterHandler is responsible for structuring the information that should be printed on the receipt.

Initializing the PrinterHandler object.

private final PrinterHandler printer = new PrinterHandler(transactionMonitor -> {
        if (transactionMonitor.getState() == DeviceState.PRINTER_SUCCESS) {

        } else {

        }
        return Unit.INSTANCE;
    });
Public Methods
onPrintReceiptModel(Bitmap receiptModel) void Starts the receipt printing process. Takes a receiptModel parameter(i.e a bitmap of the content to be printed on the receipt).

CombBitmap

The CombBitmap class is responsible for holding all the contents to be printed on the receipt. It also has a method CombBitmap#getCombBitmap() which is used to retrieve the Bitmap (i.e the contents to be printed on the receipt ) to be passed to the onPrintReceiptModel(receiptModel: Bitmap) method.

Usage

private void startPrint() {
        CombBitmap combBitmap = new CombBitmap();

        Bitmap bitmap1 = getMyBitmap(); // replace with bitmap icon

         // Print bitmap image
        combBitmap.addBitmap(bitmap)

        //Print a center-aligned text
        combBitmap.addBitmap(
            GenerateBitmap.str2Bitmap(
                "Horizon Test Slip",
                50,
                GenerateBitmap.AlignEnum.CENTER,
                true,
                false
            )
        )
				
				//Print a separator line
				combBitmap.addBitmap(GenerateBitmap.generateLine(1)) 

				// Print two texts, one aligned to the left and the other to the right.
				combBitmap.addBitmap(GenerateBitmap.str2Bitmap("Terminal ID:", "123456", 26, true, false))
				
			// Print three texts, with alignment left, center, and right respectively.
			combBitmap.addBitmap(GenerateBitmap.str2Bitmap("Status", "Items", "Cost", 23, true, false))

		// print row gap
		combBitmap.addBitmap(GenerateBitmap.generateGap(60))

		// Add a logo
		combBitmap.addBitmap(
				GenerateBitmap.formatBitmap(bitmap,GenerateBitmap.AlignEnum.CENTER)
		)
		
		// Add a header
		combBitmap.addBitmap(
				GenerateBitmap.str2Bitmap(
							title, 
							textSize, 
							GenerateBitmap.AlignEnum.CENTER, 
							true, 
							false
				)
		)
        
		// Print asterisk separator
		combBitmap.addBitmap(
				GenerateBitmap.str2Bitmap(
					"*************************************",
	        textSize,
	        GenerateBitmap.AlignEnum.CENTER,
	        true,
	        false
				)
		)     

        Bitmap content = combBitmap.getCombBitmap(); // return the contents to be printed

        printer.onPrintReceiptModel(content);
    }