Posted by a ceTe Software moderator
Hello,
The height of the overflow table can be changed based on a condition. Below is the sample code.
Document document = new Document();
Table2 table = new Table2(0, 0, 200, 400);
table.Columns.Add(100);
table.Columns.Add(100);
Page page = null;
bool addnewpage = true;
for (int i = 1; i < 400; i++)
{
Row2 row = table.Rows.Add(20);
row.Cells.Add("Row #" + i);
row.Cells.Add("Item");
}
do
{
if (addnewpage)
{
page = new Page();
document.Pages.Add(page);
page.Elements.Add(table);
addnewpage = false;
}
else
{
table.X = 300;
page.Elements.Add(table);
addnewpage = true;
}
table = table.GetOverflowRows();
if (table != null)
{
table.X = 0;
// BASED ON SOME CONDITION THE OVERFLOW TABLE HEIGHT CAN BE ADJUSTED.
if (document.Pages.Count == 2 || document.Pages.Count == 7)
table.Height = 700;
else
table.Height = 400;
}
} while (table != null);
document.Draw(@"C:\MyDocument.pdf");
Regarding the condition to determine where the parent to row should be placed, you might be able to use GetVisibleRowCount() and other
Table2 methods available to track if and when the parent row is orphaned you could decrease the height of the table so the orphaned parent row is moved to the overflow row set.
Thanks,
ceTe Software Support Team.