如何将iText段落拆分为多列? [英] How to split iText Paragraph into multiple columns?

查看:358
本文介绍了如何将iText段落拆分为多列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以将段落数据拆分为多列?

Is there any way I can split Paragraph data into multiple columns?

 Something in the paragraph which need to read by the end user.

必填段落

Something in     ---------      to read by
the paragraph    ---------      the end user.
which need       ---------

基本上,用户希望阅读短行而不是长行.

Basically user wants to read shorter lines rather than a long line.

我正在使用itextpdf-5.4.4.jar段落来显示数据.

I am using itextpdf-5.4.4.jar Paragraph to display data.

感谢您的帮助

推荐答案

请阅读我对问题的回答

Please read my answer to the question How to draw a rectangle around multiline text for which I've written DrawRectangleAroundText.

在此示例中,我们有一个Paragraph,其中包含大量文本:

In this example, we have a Paragraph with plenty of text:

Paragraph p = new Paragraph("This is a long paragraph that doesn't"
    + "fit the width we defined for the simple column of the"
    + "ColumnText object, so it will be distributed over several"
    + "lines (and we don't know in advance how many).");

我们将本段分布在不同的行上,如下所示:

And we distribute this paragraph over different lines like this:

为此,我们使用ColumnText类:

ct = new ColumnText(cb);
ct.setSimpleColumn(300f, 500f, 430f, 780f);
ct.addElement(p);
ct.go();

这只是概念的简单证明.有关ColumnText的更多信息,请阅读免费电子书文本的绝对定位部分. ="nofollow noreferrer"> StackOverflow上的最佳iText问题.这样,您就可以避免发布一个可以通过回收不到一天前发布的答案来回答的问题.

This is only a simple proof of concept. For more info about ColumnText, read the section Absolute positioning of text in the free ebook The Best iText Questions on StackOverflow. This way, you'll be able to avoid posting a question that can be answered by recycling an answer that was posted less than a day ago.

这篇关于如何将iText段落拆分为多列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆