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

Justify bug solution backport from flying saucer #351

Closed
halcsi opened this issue Apr 27, 2019 · 1 comment
Closed

Justify bug solution backport from flying saucer #351

halcsi opened this issue Apr 27, 2019 · 1 comment

Comments

@halcsi
Copy link

halcsi commented Apr 27, 2019

https://stackoverflow.com/questions/36982586/flying-saucer-generates-pdf-with-badly-justified-text/37118310#37118310

The problem seems to be that flying-soucer does not use the Paragraph of the underlying itext, but splits the text into the individual lines itself. While doing it, flying-soucer does not remove the trailing empty spaces.

A quick fix is to insert currentLine.trimTrailingSpace(c); before this call to save().

You should take 3 line in the
openhtmltopdf-core\src\main\java\com\openhtmltopdf\layout\InlineBoxing.java

			if (lbContext.isNeedsNewLine()) {
+				if (iB.getStyle().isTextJustify()) {
+             		      		currentLine.trimTrailingSpace(c);
+             		        }
                        saveLine(currentLine, c, box, minimumLineHeight,
                                maxAvailableWidth, pendingFloats,
                                hasFirstLinePEs, pendingInlineLayers, markerData,
                                contentStart, isAlwaysBreak(c, box, breakAtLine, lineOffset));

I tested and works correctly.

@halcsi
Copy link
Author

halcsi commented Apr 29, 2019

Thank you the fast finish!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants