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; }