I am using iText to generate some PDF documents. It is quite easy to draw a colored rectangle. But I would like to add some text fitting into that box. Actually the main problem is to know where to break the text. Actually it will be the equivalent problem in Swing.
With a monotype font it will be quite easy, but without? Are there any well known algorithms or other ways?
See the ColumnText class.
This sort of thing is covered extensively (along with a million other things) in the iText in Action book – I highly recommend picking up a copy.