ralfstuckert / pdfbox-layout

MIT License
156 stars 74 forks source link

Wrong text possition in frame #42

Open andrewvsk opened 7 years ago

andrewvsk commented 7 years ago

Hi,

Description: The following issue is appeared in Frame with Paragraph if setMaxWidth > 0. Depends on alignment:

Investigation: The frame border width is based on inner.getWidth() (see: TextSequenceUtil.getWidth()) which can be less then maxWidth. At the same time in TextSequenceUtil.drawText() the maxLineWidth variable is a max of getMaxWidth(lines) and maxWidth. It means that variable in common case is equal to maxWidth. As result frame width < maxLineWidth (used for text positioning)

Workaround - set paragraph maxWidth the same as width : paragraph.setMaxWidth(width); paragraph.setMaxWidth(paragraph.getWidth());

Possible fixes (frame border should be equal to max line width) :