Printer SDK

Printer SDK

Prerequisites

For Sandbox (UAT)

Users should be onboarded on iPOSpays sandbox(UAT) environment as a merchant and have a valid TPN.

For Production (Live)

Users should be onboarded on iPOSpays production environment as a merchant and have a valid TPN.

If you do not have a TPN, contact your ISO or support@dejavoo.io.

Supported Devices: Only Kozen device models are supported.

Font Size: The font size is controlled by the printer SDK, and there’s currently no option to change it. If customization is needed, an option will need to be implemented.

Supported Tags and Attributes for Printer: Only a few standard HTML tags are supported, such as <L>, <R>, <B>, <C>, <T>, and <img>.

Width Attribute: The <printer width="24"> attribute sets the paper width, allowing up to 24 characters per line. By default, the width is set to 24.

Downloading the Printer SDK

  1. Locate the printer_v3.0.aar file file provided with your Printer SDK kit.

  2. Copy the printer_v3.0.aar file file to your project directory.

Configuring Gradle Dependencies

  1. Open your project's build.gradle file (located at the module level).

  2. Add the following dependencies within the dependencies block:

implementation files "libs/printer_v3.0.aar"

Synchronizing Gradle

Click Sync Project with Gradle Files in Android Studio. This process updates your project with the Printer SDK and any additional dependencies you've included.

Accessing the Printer

Follow the steps mentioned below to access the printer:

  1. Place the provided .aar file into the lib folder of your project.

  2. In the app level build.gradle file, add the following line:

implementation files'libs/printer_v3.0.aar'

The printer_v3.0.aar file is provided with the kit. Download from here (opens in a new tab)

  1. Use the following code to initialize the printer. After initialization, set the provided callbacks to handle responses for print completion or failure.
private IntentPrintApplication intentPrintApplication = new IntentPrintApplication(this);
 
intentPrintApplication.setLaunchInterface(new PrintLauncherInterface() {
   @Override
   public void onPrintSuccess(PrintResult printResult) {
       Log.e("printer", "onPrintSuccess");
 
   }
 
   @Override
   public void onPrintFailed(PrintErrorResult errorResult) {
       Log.e("printer", "onPrintFailed");
 
   }
});
  1. Use the code below to launch the printer with the provided printer data.
intentPrintApplication.launchPrinter(request);
  1. The format of the printer input should follow the structure shown below:

The request should contain: <request><printer width=\"24\"> </printer></request> tags.

Below is a sample request:

String request = "<request><printer width=\"24\">\n<C>Happy Restaurant</C><L>10/05/23</L><R>04:07</R><C>Thank you</C><B><C>MERCHANT COPY</C></B><IMG></IMG> </printer></request>";

Image data must be sent in an img tag, and it should be a base64-encoded string of the image.

Response tags

PrintResult (a model class for success response)

Response CodeResponse Message
printStatus SUCCESS
printMessage Print successful

PrintErrorResult (a model class for failure response)

Response CodeResponse Message
errorCode print failure code
errorMessage printer failure reason
errorException If any unknown exceptions while printing

Error Codes and Their Meaning

For a complete list of error codes and their explanations, please visit our Error Codes Reference Page.