question

tellymasse avatar image
tellymasse asked tellymasse commented

How to set right allignment to receipt data while printing?

I am printing a receipt of items. I need Item names in Left side and Price of items at right side.

I am using new TextPrintJob.Builder().text(String.format("\n%-23s %6s", "Item", "Price"); to print the string with item name and price.

As items name's length are different I feel trouble to give exact spacing to the price. Is there any way to specify right allignment for printed string?

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

Jeffrey Blattman avatar image
Jeffrey Blattman answered tellymasse commented

No, the text print job is very basic and simply prints left-justified lines of text. If you need for advanced formatting you should use ViewPrintJob or ImagePrintJob.

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

tellymasse avatar image tellymasse commented ·

It works, but I get a toast message "View sent to printer". How can I remove this toast jeff? Thanks.

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

That message is coming from our code. You cannot remove it.

0 Likes 0 ·

Welcome to the
Clover Developer Community