On 24/10/2011 13:52, Dalui, Somak wrote:
Hi,
I have a situation where a PDFPTable is created iterating on a Java
object containing all data and then it is added to the document object.
Now, I have to make a page break(or create a new page) when a
condition is met while creating the PDFPTable.
If I do document.newPage(), it makes no effect. What am I missing or
what do I need to add ?
First you need to know that document.newPage() only adds a new page if
the current page isn't blank.
Now let's look at your logic.
You create a table with 1 column => nothing is added to the document.
You add a cell to the table => the table grows, nothing is added to the
document.
You add a cell to the table => the table grows, nothing is added to the
document.
You add a cell to the table => the table grows, nothing is added to the
document.
You invoke document.newPage() => iText creates a new page, unless the
current page is blank
You add a cell to the table => the table grows, nothing is added to the
document.
You add a cell to the table => the table grows, nothing is added to the
document.
You add a cell to the table => the table grows, nothing is added to the
document.
You invoke document.newPage() => iText doesn't add a new page, because
nothing was added to the document since the previous newPage
You add a cell to the table => the table grows, nothing is added to the
document.
You add a cell to the table => the table grows, nothing is added to the
document.
You add a cell to the table => the table grows, nothing is added to the
document.
You add the table to the document => A table with nine rows is added to
the document.
It should be obvious that row 4 and 7 don't start on a new page.
You've built the table in memory. As long as you don't add the table to
the document, the document isn't aware that you're building a table. The
table isn't aware of the fact that you wanted row 4 and 7 to start on a
new page.
As you should now understand, this is not an iText problem; this is a
case of elementary logic.
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php