I noticed if you create a table with a header row and set KeepTogether
true, then if the table is pushed to the next page, the header doesn't
print even though the table is the first and only thing written to that
page.  Is this by design?

 

Notice the missing header on KeepTogetherTrue.pdf page 2.

 

public KeepTogetherTest() throws Exception {

      String[] files = new String[] { "KeepTogetherFalse.pdf",
"KeepTogetherTrue.pdf" };

      for (int l = 0; l < files.length; l++) {

            Document doc = new Document(PageSize.LETTER);

            PdfWriter writer = PdfWriter.getInstance(doc, new
FileOutputStream("C:/TEMP/" + files[l]));

            doc.open();

            PdfContentByte canvas = writer.getDirectContent();

            int numTables = 5;

            int numColumns = 1;

            for (int t = 1; t <= numTables; t++) {

                  PdfPTable table = new PdfPTable(numColumns);

                  table.setWidthPercentage(100f);

                  table.setSpacingBefore(18f);

                  table.setHeaderRows(1);

                  table.setSkipFirstHeader(true);

                  table.setKeepTogether((l == 0) ? false : true);

                  PdfPCell header = new PdfPCell();

                  header.setColspan(numColumns);

                  header.setBackgroundColor(Color.GRAY);

                  header.setHorizontalAlignment(Element.ALIGN_MIDDLE);

                  header.addElement(new Phrase("TABLE HEADER"));

                  table.addCell(header);

                  for (int r = 1; r <= 12; r++) {

                        table.addCell("table " + t + " row " + r);

                  }

                  doc.add(table);

            }

            doc.close();

      }

}

 


The PEN is now mightier than the PIN. Simply use your PEN 
instead of your PIN and sign for your PEFCU Visa Check Card 
purchases. Earn bonus points redeemable for gift and travel 
awards. Combine PEFCU Visa check card and credit card points 
for even more rewards.


***This is a transmission from Purdue Employees Federal Credit
Union (PEFCU) 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.***

Attachment: KeepTogetherTrue.pdf
Description: KeepTogetherTrue.pdf

Attachment: KeepTogetherFalse.pdf
Description: KeepTogetherFalse.pdf

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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/

Reply via email to