I\'m trying to add some strings, images and tables into my pdf file (there have to be several pages) but when i try to use ColumnText
(I use this because I want
There are three options:
How do you know if the content doesn't fit?
You can add the content in simulation mode first, and test if all the content was 'consumed':
int status = ct.go(true);
boolean fits = !ColumnText.hasMoreText(status);
Based on the value of fits
, you can decide to change the size of the rectangle or the content. There's an example that shows how to do this: http://itextpdf.com/examples/iia.php?id=163
If you can distribute the content over different pages, you don't need simulation mode, you just need to insert a document.newPage();
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(rect);
int status = ct.go();
while (ColumnText.hasMoreText(status)) {
document.newPage();
ct.setSimpleColumn(rect);
status = ct.go();
}
In this example rect
contains the coordinates of the rectangle.