Stacked Q&A

Flying-saucer generates PDF with badly justified text
  • 1 voting
  • 2022-05-25 00:00

    Using <p style="text-align: justify;">...</p>to justify text generates a paragraph that is not properly justified. It seems that the problem is in the empty space that is left at the end of line.

    As generated by flying-saucer: (download simple maven project)

    Paragraph generated by flying-saucer

    In contrast to the expected rendering as in a browser: (see jsfiddle)

    Justified in browser

    Is there any known workaround for this? Thanks

  • 1 823 0 0
첨부 파일
총 1개의 답변이있습니다.
  • 답변일: 2022-05-25 00:00

    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().

  • 0 0 채택된 답변 퍼블 채택!