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

Alignment Issue for Elements Below Image #42

Open
rajinikanth0601 opened this issue Nov 5, 2024 · 1 comment
Open

Alignment Issue for Elements Below Image #42

rajinikanth0601 opened this issue Nov 5, 2024 · 1 comment

Comments

@rajinikanth0601
Copy link

This is a follow-up to issue #15, as it seems the problem wasn't fully resolved before the issue was closed . The alignment for elements below the image on the Everycom printer (EC 400) is not working in newer versions of the library (>=3.0.0).

It seems that recent refactoring related to alignment seems to have introduced this issue. The .align() method is not working for elements below image, but using a raw alignment command works, indicating that the printer itself is functioning properly.

Here are the test cases I have tried:

Case 1 :

encoder.raw([ 0x1B, 0x61, 0x02 ]);
encoder.line('Text with right alignment 1');
encoder.image(img, 400, 400);
encoder.raw([ 0x1B, 0x61, 0x00 ]);
encoder.line('Text with left alignment 2');

Case 2 :

encoder.align('right');
encoder.line('Text with right alignment 1');
encoder.image(img, 400, 400);
encoder.align('left');
encoder.line('Text with left alignment 2');

Case 3 :

encoder.align('right');
encoder.line('Text with right alignment 1');
encoder.image(img, 400, 400);
encoder.raw([ 0x1B, 0x61, 0x00 ]);
encoder.align('left');
encoder.line('Text with left alignment 2');

Case 4 :

encoder.align('right');
encoder.line('Text with right alignment 1');
encoder.image(img, 400, 400);
encoder.raw([ 0x1B, 0x61, 0x00 ]);
encoder.align('center');
encoder.line('Text with center alignment 2');

Case 5 :

encoder.align('right');
encoder.line('Text with right alignment 1');
encoder.image(img, 400, 400);
encoder.raw([ 0x1B, 0x61, 0x01 ]);
encoder.align('center');
encoder.line('Text with center alignment 2');

Please let me know if you need more details or examples. Thank you!

@NielsLeenheer
Copy link
Owner

The change in the way alignment works is very deliberate, as the default way printers deal with alignment causes issues. It also does not work with tables, boxes and in certain other situations with text wrapping. That is why the library now uses spaces to indent text. That should work reliable.

The issue you are seeing is not due to the new way of handling alignment. It even looks like it is due to the old way of handling alignment. Because images are still aligned in the old way.

Your printer apparently does not process the align command before an image. That is why your image is left aligned when it should be right aligned.

In the image below you can see the first line of text being aligned using spaces. Then for the image it sends an align=right command. Then the image data. And finally an align=left command. These commands are identical as the raw commands your are sending in your example.

Screenshot 2024-11-07 at 14 08 20

Somehow it instead applies that align command when it reaches the next line - after the image data - which is a text line. And the align command after the image is ignored altogether, making the text right aligned. This absolutely is a printer issue.

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

No branches or pull requests

2 participants