ralfstuckert / pdfbox-layout

MIT License
156 stars 74 forks source link

Fit text into space #5

Closed kwladyka closed 7 years ago

kwladyka commented 8 years ago

I have to fit text into precise width, height.

For example i have to write on PDF "foo bar baz foo bar baz foo bar baz foo bar baz ..." in XxY. If it doesn't fit i have to decrease font-size as long as it will start fit. How can i do it? How to check how much space parahraph will consume on the page?

ralfstuckert commented 8 years ago

Just ask the paragraph for its width/height. You can constrain the width using setMaxWidth(), which will lead to a text layout. Then ask for the resulting height. If it does not fit your needs, you have to use a smaller font size. If the paragraph fits your needs, add it to the document.

Is that what you want?

ralfstuckert commented 8 years ago

Please let me know, if this fulfills your needs, so I may close the issue.

ralfstuckert commented 7 years ago

No feedback in half a year, so will close this issue. Sorry.