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

Justified text sometimes expands past maxWidth #2553

Closed
simonbengtsson opened this issue Aug 9, 2019 · 9 comments
Closed

Justified text sometimes expands past maxWidth #2553

simonbengtsson opened this issue Aug 9, 2019 · 9 comments
Labels

Comments

@simonbengtsson
Copy link
Contributor

Sometimes when drawing text with the justify alignment option set the text expands past maxWidth. Red lines in the below example highlights the maxWidth length and the fillerrrrr word can be seen expanding past it.

Screenshot 2019-08-09 at 14 19 12

The same example works when using left alignment:

Screenshot 2019-08-09 at 14 19 30

Here is the code for the example:

var doc = new jsPDF();

// maxWidth lines
doc.setDrawColor(255, 0, 0);
doc.setLineWidth(0.5);
doc.line(10, 10, 10, 33);
doc.line(60, 10, 60, 33);

doc.text(10, 20, 'filler shortword longerword fillerrrrrr', {
    maxWidth: 50,
    align: 'justify'
});

doc.save('table.pdf');
@bwl21
Copy link
Contributor

bwl21 commented Feb 20, 2020

this seems to be a bug.

You can reproduce and playaround this in Live Demo.

if you add a space to the string, it works well.

var doc = new jsPDF();

// maxWidth lines
doc.setDrawColor(255, 0, 0);
doc.setLineWidth(0.5);
doc.line(10, 10, 10, 33);
doc.line(60, 10, 60, 33);

doc.text(10, 20, 'filler shortword longerword fillerrrrrr ', {
    maxWidth: 50,
    align: 'justify'
});

@github-actions
Copy link

github-actions bot commented Jul 8, 2020

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

@simonbengtsson
Copy link
Contributor Author

Still an issue

@themacboy
Copy link

themacboy commented Jul 9, 2020 via email

@simonbengtsson
Copy link
Contributor Author

This should not be closed?

@HackbrettXXX
Copy link
Collaborator

Interesting, I thought commenting would be enough such that the bot doesn't close the issue.

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

@simonbengtsson
Copy link
Contributor Author

Still relevant

@SimonPrins
Copy link
Contributor

@simonbengtsson @HackbrettXXX I believe this can be closed now. This is what the example looks like in the playaround:
justified-fix

I believe this PR fixed it: #3168
Which was released with the 2.4.0 release

@Uzlopak Uzlopak closed this as completed Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants