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

Set print width #284

Open
jasikpl123 opened this issue Oct 28, 2024 · 5 comments
Open

Set print width #284

jasikpl123 opened this issue Oct 28, 2024 · 5 comments

Comments

@jasikpl123
Copy link

Hey,
i would like to set print width by limiting to 40 characters per line (using font B).
It work perfectly fine until I want to align to center - the printer just prints it thinking i'm using 80mm paper (i want to use 58mm instead) so the message is cut in half...
Any solutions?
Thanks x

@igorocampos
Copy link
Collaborator

Which commands are you using to align text to center?

@jasikpl123
Copy link
Author

Which commands are you using to align text to center?

e.CenterAlign()

@igorocampos
Copy link
Collaborator

From EPSON's handbook:
image
In red I believe is the why you are getting your current behavior

@jasikpl123
Copy link
Author

Then how do i solve it? Can i specify the number of characters in one line when justifying the text?

@igorocampos
Copy link
Collaborator

igorocampos commented Oct 28, 2024

But if you know your line is always gonna be 40 chars long, it is probably easier to build an internal method that pads empty space in order to center align your text.

quick search in the internet, and found this for example

static string center(string text)
{
	int paperWidth = 40;
	int stringWidth = text.Length;
	int spaces = (paperWidth / 2) + (stringWidth / 2);

	return text.PadLeft(spaces);
}

You can check it out here: https://dotnetfiddle.net/E07KuV

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