Configure printings
With the printing feature, you can manage prints directly from your application and obtain them from the assigned terminal or send the print to a Bluetooth printer.
With this feature, you can print purchase tickets and integrate custom prints. This functionality is useful for businesses that need to print complementary receipts, such as Electronic Tax Documents (DTE), coupons, or images.
It is possible to use the thermal printer of Point Smart devices to print bitmap images or custom images from patterns called Custom Tags.
To print bitmap images with the Point terminal printer, use the print function from the BitmapPrinter class of the MPManager object. In the imageToPrint field, specify an image in PNG or JPEG format, with Base64 encoding and a maximum size of 1MB.
See below an example of how to print an image.
val bitmapPrinter = MPManager.bitmapPrinter
val imageToPrint: Bitmap = bitmap // Get the Bitmap image that will be printed
bitmapPrinter.print(imageToPrint) { response ->
response.doIfSuccess { printResult ->
// Handle successful printing
}.doIfError { error ->
// Handle printing operation error
}
}
final BitmapPrinter bitmapPrinter = MPManager.INSTANCE.getBitmapPrinter();
final Bitmap imageToPrint = bitmap // Get the Bitmap image that will be printed
final Function1<MPResponse<String>, Unit> callback = (final MPResponse<String> response) -> {
if (response.getStatus() == ResponseStatus.SUCCESS) {
// Handle successful printing
} else {
// Handle printing operation error
}
return Unit.INSTANCE;
};
bitmapPrinter.print(imageToPrint, callback);
To perform printing on an external printer, you must first pair it with the Point terminal via Bluetooth. After pairing, use the print function from the BluetoothPrinter class of the MPManager object to perform the printing. In the dataToPrint field, provide the text sequence to be printed.
address field.See below an example of how to perform printing.
val bluetoothPrinter = MPManager.bluetooth.printer
bluetoothPrinter.print(dataToPrint, address) { response ->
response
.doIfSuccess { printerResult ->
// Handle successful printing result
when (printerResult) {
BluetoothPrinterResult.SUCCESS -> {
// Printing performed successfully
// ... Perform additional actions if necessary
}
BluetoothPrinterResult.NEED_SELECTION_DEVICE -> {
// More than one paired device, address must be specified
// ... Perform additional actions if necessary
}
else -> { // Other successful result cases }
}
}
}.doIfError { error ->
// Handle error case if necessary
}
}
final BluetoothPrinter bluetoothPrinter = MPManager.INSTANCE.getBluetooth().getPrinter();
final Function1<MPResponse<BluetoothPrinterResult>, Unit> callback =
(final MPResponse<BluetoothPrinterResult> response) -> {
if (response.getStatus() == ResponseStatus.SUCCESS) {
// Perform additional actions if necessary
} else {
// Handle error case if necessary
}
return Unit.INSTANCE;
};
bluetoothPrinter.print(dataToPrint, address, callback);
The response may contain the following information:
| Field | Type | Description |
dataToPrint | String | Text sequence that will be printed. |
address | String | The address of the Bluetooth printer that will be used. |
| Status | Description |
CONNECTION_FAILED | The connection to the printer failed. |
ERROR_UNDEFINED | An error of unknown cause occurred. |
SUCCESS | Printing was completed successfully. |
NEED_SELECTION_DEVICE | It is necessary to specify the printer address when there are multiple paired devices. |
ERROR_DATA_TO_PRINT_NULL | The data provided for printing is null. |
ERROR_PRINTER_NOT_FOUND | No paired printer was found. |