How to split iText Paragraph into multiple columns?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 02:27:09

问题


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

Current Paragraph

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

Required Paragraph

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

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

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

Thanks for you help


回答1:


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

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:

For this purpose, we use the ColumnText class:

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

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.



来源:https://stackoverflow.com/questions/29042035/how-to-split-itext-paragraph-into-multiple-columns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!