简体   繁体   English

iText / Swing:在框中打断文本

[英]iText/Swing: Breaking text in a box

I am using iText to generate some PDF documents. 我正在使用iText生成一些PDF文档。 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. 实际上,这将是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. 请参见ColumnText类。

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. 《 iText in Action》一书广泛涵盖了此类内容(以及其他一百万种内容)-我强烈建议您拿起副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM