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

PdfUtil.getStringWidth() can return incorrect results for multi-line strings #131

Open
asdf00000 opened this issue Jul 20, 2021 · 0 comments

Comments

@asdf00000
Copy link

The method PdfUtil.getStringWidth() should calculate the length of every line, not just the line that contains the longest string.
The width of the individual letters can be very different so a string with less characters can be wider than a string with more characters. For instance, a single w is wider then three times i.

Example:

String line1 = "iii";
String line2 = "www"; float w1 = PdfUtil.getStringWidth( line1 + "\n" + line2, PDType1Font.HELVETICA, 10); float w2 = PdfUtil.getStringWidth( line2 + "\n" + line1, PDType1Font.HELVETICA, 10);

result:
w1 = 6.66
w2 = 21.66

both should return 21.66

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

1 participant