Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout package not ready for escpos rendering #11

Open
FouadRaheb opened this issue Dec 27, 2023 · 5 comments
Open

Layout package not ready for escpos rendering #11

FouadRaheb opened this issue Dec 27, 2023 · 5 comments
Assignees

Comments

@FouadRaheb
Copy link

The layout package currently only renders properly on HTML but not on ESC/POS.

I think the layout package is an essential part of any receipt, without it it's not possible to print lines with both right and left texts which is needed in any receipt type.

@zaviermiller
Copy link
Collaborator

I am planning on working on this package today, so good timing! I will update when I have made progress :)

@FouadRaheb
Copy link
Author

That's awesome! I built all of my receipt template using row and col nodes, then after printing I noticed it is not ready yet haha

@zaviermiller
Copy link
Collaborator

@FouadRaheb I worked on it a bit, but it's been hard to test my changes since I don't have a receipt printer with me and won't for a couple of days so I won't be able to ensure the layout package is working until then. I have the changes I made on the branch for this issue if you want to test and maybe take a stab at getting it working.

My general strategy for getting this working is to do the following:

  1. In the row node, enter page mode
  2. In each col node compute the offset that the col should start at based on the number of cols already in a "line"
  3. Set the starting x position of that col and set the y position to 0 and update the line length for the children context so that line breaks will be placed correctly.
  4. Render children

This approach has gotten me close, and having a colleague test it out gives this result:
IMG_1429

As you can see, the two columns are placed on top of each other. After reading the manual, I believe this is because I've set the x position of the second column too high.

@zaviermiller zaviermiller self-assigned this Dec 28, 2023
@FouadRaheb
Copy link
Author

Check this out, I've used this library in the past to generate ESC/POS commands, it uses some sort of table with predefined columns layout.

@zaviermiller
Copy link
Collaborator

Awesome! I'll check that out and see if it can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants