Testing with printer receipt images

You can use Clover’s image print drivers to test receipts without requiring a Clover devkit. Every time you want to test with a printer receipt using the emulator, the driver saves the receipt output as a PNG file.

📘

NOTE

These drivers work only in the sandbox environment.

Enabling image print drivers

To set up the image print drivers:

  1. Install and launch your test Android app on the emulator.
  2. In Android Studio, select View > Tool Windows > Terminal (Alt+F12/Option+F12).
  3. To enable the Clover image printer drivers, enter the following command:
adb shell am startservice -n "com.clover.engine/.services.ReceiptPrinterPlugins.image.EnableImagePrintService" -a "enable"

Once enabled, the drivers can be discovered as printers using the Printers app.

  1. In the Printers app, select the green + button from the bottom left of the screen.
  2. Select Add Receipt Printer or Add Order Printer.
  3. From the available list, select the image printer driver you want to add. The drivers emulate the different widths of printer receipts.

To use the image print drivers, simply print a receipt for an order. The output is saved under /sdcard/receipts.

Sample output:

$ adb shell ls /sdcard/receipts
...
receipt-2019-03-22_18-16-47-993-00.png
receipt-2019-03-22_18-16-47-993-01.png
receipt-2019-03-22_18-16-47-993-02.png

The receipt file name format is receipt-{date}-{time}-{part}.png where part is the receipt part number. Receipts can be long, which is why they are printed in parts to avoid saving large images. In the sample output above, a single receipt is split into 3 parts.

Disabling image print drivers

To disable the Clover image printer drivers, enter the following command:

adb shell am startservice -n "com.clover.engine/.services.ReceiptPrinterPlugins.image.EnableImagePrintService" -a "disable"

📘

NOTE

Disabling the image printer drivers removes the discovery of the image printer drivers, but does not remove the image printer options that are configured for printing.


Did this page help you?