I'm almost there, thank you Paolo for your continued assistance.

I either need to know that the next row I am going to write will not fit
and create a new PdfPTable, flush out the written content from PdfPTable
so the unwritten rows remain, or create a new PdfPTable with the
unwritten rows from the previous page.


After adding a row, I can use PdfPTable.getTotalHeight() to find my
position on the page after a row was added.  However, what if the last
added column is past the end of the bottom page margin?

        table.addCell(...);  // Fill up the row with content
        if ( table.getTotalHeight > sizeOfPageWithMargins ) {
                // Now I have written one too many rows to fit on a page
                table.deleteLastRow();
                table.writeSelectedRows(...); // write all the rows in
the table
                table = new PdfPTable(...);
                // Now I need to re-add the last row of data again...
                table.addCell(...);
        }


Is there some other way to do this without having to manually re-add the
last column?  Something like

        table.addCell(...);
        if ( table.getTotalHeight > sizeOfPageWithMargins ) {
                table.writeSelectedRows(0, table.size() - 1, ...); //
write all but the last row
                // Create a new PdfPTable containing only the 'overflow'
row from the last table
                table = new PdfPTable(table, table.size());
                // Don't need to re-add the table
        }


Or am I missing some other concept that makes this solution easier?

Thank you - please let me know if I can clarify.


Daniel Wellman
U.S. Trust
Ph: (201) 533-6157

-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 22, 2004 11:28 AM
To: Wellman, Daniel; [EMAIL PROTECTED]
Subject: RE: [iText-questions] PDFPTable page splitting issues

You have some examples at itextpdf.sf.net.
The general idea is:

PdfPTable table = new PdfPTable(..);
table.setTotalWidth(doc.right() - doc.left());
// add the rows

You can get the individual row height, just write some rows, etc.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Wellman, Daniel
> Sent: Wednesday, September 22, 2004 3:13 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [iText-questions] PDFPTable page splitting issues
>
>
> Thanks for the suggestion, Paulo.  I'm not clear on what exactly you
> mean -- do you mean that I should continue to use
> table.writeSelectedRows, but manually keep track of the
> current vertical
> displacement from the top of the page for the current row and
> decide if
> I need to break the page using logic similar to what's in fitPage?
>
>   return table.getTotalHeight() <= indentTop() - currentHeight -
> indentBottom() - margin;
>
>
> If so, it sounds like I would need to calculate the height of the row
> before adding it (since the row could be one or more lines tall)
>
> Is there an example in the iText example source package that
> I can look
> at for this concept?
>
>
>
> Thank you!
>
> Daniel Wellman
>
> -----Original Message-----
> From: Paulo Soares [mailto:[EMAIL PROTECTED]
>
> Sent: Tuesday, September 21, 2004 6:30 PM
> To: Wellman, Daniel; [EMAIL PROTECTED]
> Subject: Re: [iText-questions] PDFPTable page splitting issues
>
> Do your own layout. After all, you are already using
> writeSelectedRows(),
> you don't need fitsPage().
>
> Best Regards,
> Paulo Soares


---------------------------------------------------------------------
The message contains confidential and/or legally privileged
information and is intended for use by the indicated addressee. 

If you are not the intended addressee: (a) any disclosure,
reproduction, distribution or action you take because of it is
strictly prohibited; (b) please return the complete message to the
sender; and (c) this message is not a solicitation for purchase or
sale or an agreement of any kind whatsoever that binds the sender.
---------------------------------------------------------------------


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to