Do your own layout. After all, you are already using writeSelectedRows(),
you don't need fitsPage().

Best Regards,
Paulo Soares

----- Original Message ----- 
From: "Wellman, Daniel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 21, 2004 19:11
Subject: [iText-questions] PDFPTable page splitting issues



First off, thank you for creating such an excellent tool and for
providing a great community mailing list.  We are evaluating iText for
use in a project and are working on a proof-of-concept that involves the
following:

-          Headers and foots on every page

-          All the content is stored in a table to provide clean rows
and columns of data (no nested tables)

-     Runs in a web application and sends response data to either the
local file system or to the HttpResponse



BACKGROUND:



We are doing this with PdfPTables for the content and page event
listeners for onEndPage to add headers and footers.  We use this method
as described in an earlier list message to determine if we have
surpassed our page boundary when iterating through our list of data to
print to the PDF file:



         // add content to table with addCell(Phrase) omitted here

         if (!writer.fitsPage(table, myMargin)) {

            table.deleteLastRow();

            i --;    // decrement our loop counter to reprint the last
row on the new page

            table.writeSelectedRows(0, -1,document.leftMargin(),
marginInfo, writer.getDirectContent());

            document.newPage();

            table = createTable(reportLayoutObject,tableCellLengths);

        }



Note that in this case, we have one collection of all of the data to be
rendered, where each element contains one row of data.  This works
perfectly, as far as we can tell.





PROBLEM:



Now we are facing a problem on a different report which does something
like this:



            Print a label row (i.e. "List of Foos:")

            Loop through a collection of foo data and print out as in
the previous example

            Print another label row (i.e. "List of Bars:")

            Loop through a collection of bar data...

            etc.





The problem I see here is that we only catch the write-past-end-of-page
condition when we are looping through a collection of data to print.
Printing the label rows runs the risk of printing beyond the page end;
if we try and call writer.fitsPage() and deleteLastRow() afterwards,
there's no way to get this label Row data back to reprint it.



This is similar to the problem/feature suggestion noted here:

http://sourceforge.net/mailarchive/message.php?msg_id=6510263





Here's my list of possible solutions - do these sound valid, or is there
one I'm missing?



1. Ideally I'd like to find out if the next row I'm about to write is
going to wrap and then create a new page.  However this requires knowing
the row height for the cells about to be written, and the dynamic row
data can wrap multiple lines.  Is there a way to get this projected row
height for the text and font and specific column of a row?



2. How about accessing the Row content and copying out the cells right
before deleteLastRow is called?  (It looks like getRow is
package-private)



3. Another solution I thought of was to create a "printRow" helper class
in our application which contains a list of cell data, with a
"printRow(PDFPTable, Document)" method which will print the row to the
table, check to see if it didn't fit, delete the last row, create a new
table, and then re-add the row to the new table .





Thanks for your advice!





Daniel Wellman



---------------------------------------------------------------------

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