Hi,
I created custom layouts to print Order and Payment Receipts both and it prints perfectly fine on the clover attached printers and also the Thermal Printer from Star Micronics TSP100. One merchant tested this custom layout printing with his Impact Printer from Star Micronics SP700, but unfortunately it didn't print. I get the width of the printer by using printer.type.numDotsWidth. The result is shown "0" for the SP700 and "576" for the clover printers. Since the width is 0 it won't print any data.
The other thing is when I send some custom data to print, it directly prints it. I used TextPrintJob to just test if it prints through my app or not. It does print using the custom text but not using the custom layout.
Below is the code that I use to measure the custom layout and send the command to print. This code works for Clover Printers and Star Micronics TSP100 but not for SP700.
try { int measuredWidth = View.MeasureSpec.makeMeasureSpec(kitchenViewWidth, View.MeasureSpec.EXACTLY); int measuredHeight = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); kitchenReceiptLayout.measure(measuredWidth, measuredHeight); kitchenReceiptLayout.layout(0, 0, kitchenReceiptLayout.getMeasuredWidth(), kitchenReceiptLayout.getMeasuredHeight()); kitchenReceiptLayout.requestLayout(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { if (printer != null) { ViewPrintJob.Builder builder = new ViewPrintJob.Builder().view(kitchenReceiptLayout); ViewPrintJob printJob = builder.build(); printJob.print(context, CloverAccount.getAccount(context), printer); } return null; } }.execute(); } catch (Exception e) { e.printStackTrace(); }
This is how I get the width of the printer. The printer here is the selected printer to print Order Receipts Only.
kitchenViewWidth = printer.type.numDotsWidth;
Please let me know if this is the right approach for SP700 or not. Thank you.