We are writing a table out with DynamicPDF, but we want to "group" the rows so a page break does not occur in the middle of the group. The groups are anywhere from one to six lines. Has anyone found a way to do this? Here's our code:
// Create a PDF Document
Document document = new Document();
Table2 table = new Table2(0, 0, 200, 700);
// Add columns to the table
table.Columns.Add(100);
table.Columns.Add(100);
// This loop populates the table
for (int i = 1; i <= 400; i++)
{
Row2 row = table.Rows.Add(20);
row.Cells.Add("Row #" + i);
row.Cells.Add("Item");
}
// This loop outputs the table to as many pages as is required
do
{
Page page = new Page();
document.Pages.Add(page);
page.Elements.Add(table);
table = table.GetOverflowRows();
} while (table != null);
There isn't a property or method to do this directly, but you can achieve this as follows:
Keep in mind that if you have the Table2.RepeatRowHeaderCount property set > 0, you'll need to include those header rows in your calculation (#2 above) for each overflow table.
Full disclosure, I work for ceTe Software, the makers of DynamicPDF.