FILTER BY TAG

Custom Printing

Use the Custom Printing feature to print custom content directly to the integrated printer of a PAX terminal. This feature enables you to print text, label-value pairs, images, barcodes, and QR codes. It is not limited to receipts and does not affect standard printed or emailed receipts.
A label-value pair consists of two related text elements: a label that describes the data and a value that displays the associated information. For example: Card (label): Visa (value) or Amount (label): 10.00 (value).

Use Custom Printing

Follow these steps to use custom printing on a PAX device with an integrated printer.
  1. Create a
    PrintLayoutFactory
    object to set a custom print layout.
    val customReceipt = PrintLayoutFactory.Builder() .addParagraph("This is Custom Receipt") .addParagraph("This is centered", AccessoryPrinter.Align.CENTER) .addParagraph("This is right", AccessoryPrinter.Align.RIGHT) .addParagraph("This is left", AccessoryPrinter.Align.LEFT) .addLabelValue("Label", "Value") .addImage(prepareImageFile("image.jpg", context)) .addBarcode( type = PrintLayout.Section.Barcode.Type.QRCODE, value = "https://www.example.com" ) .addEject() .build() // Adding an image requires the absolute file path of the image. Use this to refer to an image in your asset folder. fun prepareImageFile(imageFileName: String, context: Context): String { val inputStream = context.assets.open(imageFileName) val file = File(context.cacheDir, imageFileName) file.outputStream().use { output -> inputStream.copyTo(output) } return file.absolutePath }
  2. Retrieve the
    CustomPrintIntent
    variable from the
    mposUi
    object and use the
    startActivity
    method to initiate the custom printing flow.
    val CustomPrintIntent = mposUi.createCustomPrintIntent(customReceipt) startActivityForResult(CustomPrintIntent, MposUi.REQUEST_CODE_CUSTOM_PRINT)
  3. After the printing activity is complete, the
    onActivityResult
    method is triggered. This action returns information about the last transaction.
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { MposUi.REQUEST_CODE_CUSTOM_PRINT -> { when (resultCode) { MposUi.RESULT_CODE_PRINT_SUCCESS -> { // Printing was successful Log.d(TAG, "Printing successful.") } MposUi.RESULT_CODE_PRINT_FAILED -> { // Printing failed Log.e(TAG, "Printing failed.") } } } } }