Pular para o conteúdo principal

Impressão

Métodos de impressão do PosPinpad. Use os overloads com PrintAttributes (preferidos). O parâmetro notifyComplete controla a propagação de onPrintCompleted() — use false nas instruções intermediárias e true apenas na última.

fun print(text: String) // texto plano (legado)
fun printText(text: String, attributes: PrintAttributes, notifyComplete: Boolean = true)
fun printColumns(texts: List<String>, attributes: List<PrintAttributes>, notifyComplete: Boolean = true)
fun printImage(source: Any, width: Int, height: Int)
fun printImage(source: Any, width: Int, height: Int, attributes: PrintAttributes, notifyComplete: Boolean = true)
fun printBitmap(bitmap: Bitmap, notifyComplete: Boolean = true)
fun printQrCode(payload: String, align: Align = Align.CENTER, sizePx: Int = 200, notifyComplete: Boolean = true)
fun feedPaper(lines: Int, notifyComplete: Boolean = true)
fun feedStep(steps: Int, notifyComplete: Boolean = true)

Exemplo:

posPinpad.printText("COMPROVANTE DE VENDA", PrintAttributes(align = Align.CENTER, typeface = Typeface.BOLD))
posPinpad.printColumns(
listOf("Valor", "R$ 50,00"),
listOf(PrintAttributes(weight = 1), PrintAttributes(align = Align.RIGHT, weight = 1))
)
posPinpad.printQrCode(pixPayload, sizePx = 200)
posPinpad.feedStep(1) // destaca a bobina

Veja PrintAttributes (Align/Typeface).