Justified text sometimes expands past maxWidth
See original GitHub issueSometimes 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.
The same example works when using left alignment:
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');
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Justified text sometimes expands past maxWidth #2553 - GitHub
Sometimes when drawing text with the justify alignment option set the text expands past maxWidth. Red lines in the below example highlights ...
Read more >Android TextView Justify Text - Stack Overflow
UPDATE 2018-01-01: Android 8.0+ supports justification modes with TextView . ... (or simply "Justification", as it is sometimes ambiguously referred to).
Read more >5 Ways to Not Over Stretch the Last Line of a Justified Paragraph
Check the “Don't expand character spaces on a line that ends with SHIFT-RETURN” box and click “OK”.
Read more >Handling Long and Unexpected Content in CSS
Notice how increasing the padding creates a safe area for the icon. Now we can be sure that it won't break if the...
Read more >How do i get my paragraphs to be perfectly aligned, and ...
My paragraphs look great in a mobile version but loose there alignment when the browser is expanded. I want my paragraphs to be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@simonbengtsson @HackbrettXXX I believe this can be closed now. This is what the example looks like in the playaround:
I believe this PR fixed it: https://github.com/parallax/jsPDF/pull/3168 Which was released with the 2.4.0 release