question

Rohit Bhardwaj avatar image
Rohit Bhardwaj asked Rohit Bhardwaj commented

Orders Printing twice to only one Thermal Printer instead of two

Hi clover devs,

We are implementing multiple printers feature in our app, where the merchants can select multiple printers and the orders will print through the selected printers. We have setup 4 printers in all(2 Star micronics thermal TSP100 and 2 Star micronics impact SP700 printers). When I send print commands to all these printers both the SP700 printers are printing the data correctly whereas only one TSP100 printer prints the same order twice which should not be the case.


I want both these TSP100 printers to print the orders just like SP700 is printing the orders in each. Can you help me solve this because I have been stuck at this issue for a couple of days.
Thanks!!

Print
10 |2000

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

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered Rohit Bhardwaj commented

"When I send print commands to all these"

Can you be specific about the API you are using. Have you verified that you are not sending multiple print commands in certain cases?

3 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.

Rohit Bhardwaj avatar image Rohit Bhardwaj commented ·

I'm using ViewPrintJob to print the custom print layout for TSP100 and a TextPrintJob to print text when the printer is SP700 or with printer.type.numDotsWidth = 0. Below is the code for TSP100;

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();


I'm using a loop to send the print command one by one to these printers. The reason of using a for loop is to compare the merchant selected printer from our app with the clover printers added as Order Printers.

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ Rohit Bhardwaj commented ·

I don't see anything in the context you have provided that proves you are not calling print twice. Why don't you add a log right before the print?

0 Likes 0 ·
Rohit Bhardwaj avatar image Rohit Bhardwaj David Marginian ♦♦ commented ·

Below is the whole code which is used to compare selected printer list with clover's printer list. See the attached file for full code.


printing_loop_code.txt


I have added a log and a toast message because I don't have multiple printers attached with my Clover 2018 dev kit. The multiple printer setup is with someone else. I have seen the video for the above code which display the Toast message with all selected printer names correctly but the only problem is it does not print to both the thermal printers.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community