question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

align left and right on the same line

See original GitHub issue
What steps will reproduce the problem?
1. use Epson TM-T20
2. execute the following code
3.

What is the expected output? What do you see instead?
I would like to format a line to begin on the left with some words ("article" 
in my example) and then align on the right to write the price (15.00 € here)

What version of the product are you using? On what operating system?
python-escpos 1.0-1 on ubuntu 13.10

Please provide any additional information below.

code :
Epson.set("LEFT", "A", "", 1, 1)
Epson.text("Article 1")
Epson.set("RIGHT", "A", "", 1, 1)
Epson.text("15.00 \xd5")
Epson.text("\n")

Original issue reported on code.google.com by shu...@gmail.com on 15 May 2014 at 10:29

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
MicroJoecommented, Dec 15, 2017

I had to use this feature for receipt-like printing recently. Here is the snippet that I used (with hardcoded width from my printer):

def leftright(p, left, right, font='b'):
    if font == 'a':
        p.textln("{:<20}{:>12}".format(left, right))
    else:
        p.textln("{:<30}{:>12}".format(left, right))

Maybe we can think of a kind of API for this. At least it will help if someone wants to do this right now without using a cleaner solution (I think this is Python 3 only).

1reaction
patkancommented, Oct 6, 2016

I don’t think that escpos printers are capable of this. Probably the best way to do that is by using tabs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to apply left and right alignment to text in Word
Click to the left of the text you want to right align. For this example, click to the left of “right-aligned,” and press...
Read more >
Flush Left and Flush Right On the Same Line (Microsoft Word)
In the Alignment area, click Right. (This tells Word that this will be a right-aligned tab, just like you want.) Click on Set....
Read more >
Left Align and Right Align Text on the Same Line - CSS-Tricks
It can sometimes be useful to have some text be aligned to the left and some text be aligned to the right on...
Read more >
How to align text left and right on the same line in Microsoft Word
How to align text left and right on the same line in Microsoft Word · Go to the 'Indents and Spacing' section. ·...
Read more >
How may I align text to the left and text to the right in the same ...
<p style="text-align:left;"> This text is left aligned <span style="float:right;"> This text is right aligned </span> </p>. Run code snippet
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found