Hi everyone,
I'm new to iText, using iText 2.1.7 on Java 5 and 6.
When I'm adding elements to a ColumnText and no more space is available,
so calling go() does not return NO_MORE_TEXT. Then I call clearChunks(),
which, from my understanding, remove the extra data that was left out due
to the lack of space. So then, by calling go() again I should get
NO_MORE_TEXT (as written in the javadoc) but it's not the case.
The following code is a small example showing that. The console output is:
has more: true
has more: true
but the second one should be false. And of course the generated PDF
contains both "foo" and "bar" when I was expecting only "bar".
Am I not understanding something correctly or is there a bug here? (I had
a quick look at the source code and I think that, in clearChunks(), in case
of "composite", "compositeColumn" should also be cleared (but I'm only
guessing here)).
Regards,
Laurent.
package org.desgrange.sandbox;
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.ColumnText;
import com.lowagie.text.pdf.PdfWriter;
public class SandBox {
public static void main(final String[] args) throws Exception {
final Document document = new Document();
final PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("sandbox.pdf"));
document.open();
final ColumnText column = new
ColumnText(writer.getDirectContent());
// Create a too small column
column.setSimpleColumn(document.left(), document.top() - 5,
document.right(), document.top());
// Try to add something
column.addElement(new Paragraph("foo"));
// Of course the text does not fit
System.out.println("has more: " +
ColumnText.hasMoreText(column.go(true)));
// Lets remove extra data
column.clearChunks();
// There should not be any remaining extra data
System.out.println("has more: " +
ColumnText.hasMoreText(column.go(true)));
// Make the column bigger and add an other paragraph
column.setSimpleColumn(document.left(), document.top() - 50,
document.right(), document.top());
column.addElement(new Paragraph("bar"));
column.go();
document.close();
}
}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/