internal void AddPTable(PdfPTable ptable)
{
ColumnText ct = new ColumnText(writer.DirectContent);
// if the table prefers to be on a single page, and it wouldn't
//fit on the current page, start a new page.
if (ptable.KeepTogether && !FitsPage(ptable, 0f) && currentHeight > 0) {
NewPage();
}
if (currentHeight == 0) {
ct.AdjustFirstLine = false;
}
ct.AddElement(ptable);
bool he = ptable.HeadersInEvent;
ptable.HeadersInEvent = true;
int loop = 0;
while (true) {
ct.SetSimpleColumn(IndentLeft, IndentBottom, IndentRight, IndentTop - currentHeight);
int status = ct.Go();
if ((status & ColumnText.NO_MORE_TEXT) != 0) {
text.MoveText(0, ct.YLine - IndentTop + currentHeight);
currentHeight = IndentTop - ct.YLine;
break;
}
if (IndentTop - currentHeight == ct.YLine)
++loop;
else
loop = 0;
if (loop == 3) {
throw new DocumentException(MessageLocalization.GetComposedMessage("infinite.table.loop"));
}
NewPage();
}
ptable.HeadersInEvent = he;
}