question

kyle avatar image
kyle asked Jeffrey Blattman commented

Slow printer on Clover Station

Hi,

We have a client using our Clover App, which print an image on their receipt.
And they are getting a 30s delay on the printing queue every time they do it.

They are using a Clover Station (11") and the Clover Station printer.
When they check out with the Clover Station, our app would popup a toast, and send a Bitmap to the printer. We are seeing the toast popup at the right time, however, the receipt itself would not comes out until after 30s.
Also they printer queue is blocked, and since they use the same printer for customer receipt, they weren't able to print customer receipt until after the our receipt comes out.

We know our app works fine on other clients that has the same set up (Clover Station 11")
Wondering if anyone has any idea on how to debug/ fix this problem.


=-=-=- edit -=-=-=
here are part of the code--


public void printFlierForOrder(Order order, Merchant merchant, Printer printer,....){
//......
//......
    Bitmap finalBitmap = generateOutPutBitmap(outputText, ..... bPrintLandscape, receiptWidth);

    // actual print
    try {
        Account account = CloverAccount.getAccount(context);
        new ImagePrintJob.Builder().bitmap(finalBitmap).build().print(getApplicationContext(), account, printer);

        // let user know WE printed, Toast need to runs on UI thread / main thread
            Handler handler = new Handler(Looper.getMainLooper());
            handler.post(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(context, "printing flier, visit the Receipt Assistant app for settings", Toast.LENGTH_SHORT).show();
                }
            });
    } catch (Exception e){
        Log.d("Wali", "Cannot print, caught: " + e);
    }
}




And we use get the Bitmap from Android's View--
private Bitmap generateOutPutBitmap(String outputText, int iTextSize, Bitmap outputBitMap,  int iQrCodeSize,  boolean bEnableCustomMessage, boolean bEnableQrMessage, boolean bPrintLandscape, int receiptWidth){

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setGravity(Gravity.CENTER);
    if (bPrintLandscape) {
        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    } else {
        linearLayout.setOrientation(LinearLayout.VERTICAL);
    }

    LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    // Changes the height and width to the specified *pixels*
    linearLayoutParams.width = receiptWidth;
    linearLayoutParams.setMargins(0, 0, 0, 0);
    linearLayout.setLayoutParams(linearLayoutParams);
    linearLayout.setDividerPadding(0);
    linearLayout.setBackgroundColor(Color.WHITE);
    //linearLayout.setBackgroundColor(Color.BLACK);

    TextView textView = new TextView(context);
    try {
        textView.setText(Html.fromHtml( outputText.replaceAll("\n","<br/>") ));
    } catch (Exception e){
        textView.setText(outputText);
    }
    textView.setTextColor(Color.BLACK);
    ViewGroup.LayoutParams textViewParams = new ViewGroup.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);

    int textViewWidth = 0;
    if (bPrintLandscape) {
        textViewWidth = receiptWidth - iQrCodeSize;
        textView.setGravity(Gravity.LEFT);
    } else {
        textViewWidth = receiptWidth;
        textView.setGravity(Gravity.CENTER);
    }

    textViewParams.width = textViewWidth;
    textView.setLayoutParams(textViewParams);
    textView.setMaxWidth(textViewWidth);

    textView.setTextSize(iTextSize);

    ImageView iv = new ImageView(context);
    iv.setImageBitmap(outputBitMap);

    if (bEnableCustomMessage)
        linearLayout.addView(textView);
    if (bEnableQrMessage)
        linearLayout.addView(iv);

    View v = linearLayout;
    v.measure(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    Bitmap b = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
    v.draw(c);

    return b;
}
Print
16 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

Can you provide an MCVE that shows the problem? Just a simple app that prints a receipt that causes the delay. Since you don't say how you are adding the QR code to the receipt or how you are printing it's really hard to provide any insight.

0 Likes 0 ·
kyle avatar image kyle Jeffrey Blattman ♦♦ commented ·

Sorry, what’s MCVE again? it would be this app. https://www.clover.com/appmarket/apps/2TVTAT274Y77R

more about the app:

First, the app listens to the payment event,

Then, it will generate a bitmap picture,

And send it to the default printer.

After that it show a toast on screen.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ kyle commented ·

https://stackoverflow.com/help/mcve. I know your app can do it, but I don't have the source for that.

0 Likes 0 ·
Show more comments

0 Answers

Welcome to the
Clover Developer Community