The SynqpayPrinter module integrates with the built-in thermal printer on Synqpay devices, allowing developers to create structured print jobs using the Printer Abstraction Layer (PAL).
The print method accepts a Bundle object representing the document to be printed. The Bundle is constructed using the SynqpayPAL package.
Printer Abstraction Layer (PAL)
The SynqpayPAL package provides the necessary tools for building structured, customizable printable documents. It offers options for adjusting text direction, alignment, and line customization.
SynqpayPAL class
Direction Enum
LTR: Left-to-right text direction (default).
RTL: Right-to-left text direction.
Align Enum
START: Aligns text to the left.
END: Aligns text to the right.
CENTER: Centers the text.
Key Defaults
Direction: Left-to-Right (LTR)
Alignment: Start
Text size: 14 (inherited from the line, but can be overridden for specific text)
Finalizes the document into a Bundle for printing.
ILine Interface
The ILine interface customizes the layout of text elements within a line.
Working Modes
Regular Mode: Text elements are added sequentially without spacing. Alignment applies only to the entire line, not individual text elements.
Fill Last Mode: The last text element stretches to fill the remaining space in the line. Alignment can only be adjusted for the last element.
Weight Mode: Space allocation is proportional to the weight of text elements. The fillLast property is ignored. Alignment can be applied to all text elements because they occupy distinct spaces.
importandroid.os.Bundle;importSynqpayPAL.*;// Create a new documentIDocumentdocument=SynqpayPAL.newDocument();ILineline1=document.addLine();line1.addText().text("Hello");line1.addText().text("World!");document.addSpace(30);document.addLine().addText().text("Fill Last Mode").bold(true);document.addDivider(4);ILineline2=document.addLine();line2.fillLast(true);line2.addText().text("Hello");line2.addText().text("World").align(PAL.Align.END);document.addSpace(30);document.addLine().addText().text("Weight Mode").bold(true);document.addDivider(4);ILineline3=document.addLine();line3.addText().text("Hello").weight(1);line3.addText().text("World").weight(1);ILineline4=document.addLine();line4.addText().text("Another").weight(1);line4.addText().text("Text of line").weight(1);document.addSpace(10);ILineline5=document.addLine();line5.addText().text("ITEM").weight(6);line5.addText().text("QTY").weight(2);line5.addText().text("PRICE").weight(3).align(PAL.Align.END);ILineline6=document.addLine();line6.addText().text("Apples").weight(6);line6.addText().text("1kg").weight(2);line6.addText().text("$1.00").weight(3).align(PAL.Align.END);ILineline7=document.addLine();line7.addText().text("Coca Cola 1,5l").weight(6);line7.addText().text("3 pcs").weight(2);line7.addText().text("$10.00").weight(3).align(PAL.Align.END);ILineline8=document.addLine();line8.addText().text("Bread 1,5l").weight(6);line8.addText().text("3 pcs").weight(2);line8.addText().text("$10.00").weight(3).align(PAL.Align.END);// Finalize and printBundlebundle=document.bundle();try{printer.print(bundle);}catch(RemoteExceptione){thrownewRuntimeException(e);}