I think I've traced the (presumed) bug to this method in PdfDocument:

https://itext.svn.sourceforge.net/svnroot/itext/trunk/itext/src/main/jav
a/com/itextpdf/text/pdf/PdfDocument.java

boolean fitsPage(final PdfPTable table, final float margin) {
  if (!table.isLockedWidth()) {
        float totalWidth = (indentRight() - indentLeft()) *
table.getWidthPercentage() / 100;
        table.setTotalWidth(totalWidth);
  }
  // ensuring that a new line has been started.
  ensureNewLine();
  return table.getTotalHeight() + (currentHeight > 0 ?
table.spacingBefore() : 0f) <= indentTop() - currentHeight -
indentBottom() - margin;
}

If the table has header rows that are set skipFirstHeader, then
getTotalHeight() needs to take that into account:

Maybe something like:

Float spaceNeeded = table.isSkipFirstHeader() ? table.getTotalHeight() -
table.getHeaderHeight() ? table.getTotalHeight();
Return spaceNeeded + (currentHeight > 0 ? table.spacingBefore() : 0f) <=
indentTop() - currentHeight - indentBottom() - margin;

The fitsPage method is only called if getKeepTogether() is true, so that
should do it

Thanks,

Jason

-----Original Message-----
From: Jason Berk [mailto:jb...@purduefed.com] 
Sent: Friday, April 13, 2012 3:53 PM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] table forced to next page

I have a table with 2 header rows and 4 body rows....all forced to be 1"
tall

The width is locked, so the total height of the table is 6".....I get
that.

I set the following options on the table:
setHeaderRows(2)
setSkipFirstHeader(true)
setKeepTogether(true)

my document has 5" of vertical space remaining, but when I add the table
using document.add(table), the table is forced to the next page.  I'm
assuming that's because my 6" table won't fit in my 5" remaining space.
The issue is the header rows shouldn't be included in this math, because
they are skipped.  Really, I have a 4" table that *can* fit in the
remaining 5" space....it's the two header rows that force the page break
and those rows aren't even printing, so it's very obvious to the eye
there's enough room.

Is this something that can/should/will be "fixed/changed"?  If not, how
can I go about patching and resubmitting?

Thanks for any help/direction....

Jason Berk
jb...@purduefed.com


This is a transmission from Purdue Federal Credit Union (Purdue Federal)
and is intended solely for its authorized recipient(s), and may contain
information that is confidential and or legally privileged. If you are
not an addressee, or the employee or agent responsible for delivering it
to an addressee, you are hereby notified that any use, dissemination,
distribution, publication or copying of the information contained in
this email is strictly prohibited. If you have received this
transmission in error, please notify us by telephoning (765)497-3328 or
returning the email. You are then instructed to delete the information
from your computer. Thank you for your cooperation.


------------------------------------------------------------------------
------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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
This is a transmission from Purdue Federal Credit Union (Purdue Federal) and is 
intended solely for its authorized recipient(s), and may contain information 
that is confidential and or legally privileged. If you are not an addressee, or 
the employee or agent responsible for delivering it to an addressee, you are 
hereby notified that any use, dissemination, distribution, publication or 
copying of the information contained in this email is strictly prohibited. If 
you have received this transmission in error, please notify us by telephoning 
(765)497-3328 or returning the email. You are then instructed to delete the 
information from your computer. Thank you for your cooperation.


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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

Reply via email to