Dominic Maricic wrote:
Any idea why I'm getting the giant row that takes up all of page 2? It only happens when the content following it is greater than a page.
This is expected behavior. Please read what the book says about splitting tables. I don't know exactly what you need, but I've made a small standalone example. If you remove the line setSplitLate(false); you'll see the example behaves the way you describe. With setSplitLate(false), you don't get the 'giant row'. You can also introduce setSplitLate in the master table. br, Bruno
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
public class NestedTables {
public static void main(String[] args) {
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer
PdfWriter.getInstance(
// that listens to the document
document,
// and directs a PDF-stream to a file
new
FileOutputStream("nested_table.pdf"));
// step 3: we open the document
document.open();
// step 4: we add a table to the document
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
table.setHeaderRows(1);
PdfPCell h1 = new PdfPCell(new Paragraph("Header of
nested table"));
h1.setGrayFill(0.7f);
table.addCell(h1);
for (int row = 1; row <= 10; row++) {
if (row % 3 == 0) {
table.addCell(getTable(true));
}
else {
table.addCell(getTable(false));
}
}
document.add(table);
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
protected static PdfPTable getTable(boolean large) {
PdfPTable table = new PdfPTable(2);
PdfPCell cell = new PdfPCell(new Phrase("cell with colspan 2"));
cell.setColspan(2);
table.setSplitLate(false);
table.addCell(cell);
table.addCell("test");
if (large) {
cell = new PdfPCell(new Phrase("This is a test. "));
for (int i = 0; i < 100; i++) {
cell.addElement(new Phrase("This is a test. "));
}
table.addCell(cell);
}
else {
table.addCell("test");
}
return table;
}
}
smime.p7s
Description: S/MIME Cryptographic Signature
------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
