public PdfPTable CreatePdfPTable() {
if (!convert2pdfptable) {
throw new BadElementException("No error, just an old style table");
}
AutoFillEmptyCells = true;
Complete();
PdfPTable pdfptable = new PdfPTable(widths);
pdfptable.ElementComplete = complete;
if (NotAddedYet)
pdfptable.SkipFirstHeader = true;
SimpleTable t_evt = new SimpleTable();
t_evt.CloneNonPositionParameters(this);
t_evt.Cellspacing = cellspacing;
pdfptable.TableEvent = t_evt;
pdfptable.HeaderRows = lastHeaderRow + 1;
pdfptable.SplitLate = cellsFitPage;
pdfptable.KeepTogether = tableFitsPage;
if (!float.IsNaN(offset)) {
pdfptable.SpacingBefore = offset;
}
pdfptable.HorizontalAlignment = alignment;
if (locked) {
pdfptable.TotalWidth = width;
pdfptable.LockedWidth = true;
}
else {
pdfptable.WidthPercentage = width;
}
foreach (Row row in this) {
IElement cell;
PdfPCell pcell;
for (int i = 0; i < row.Columns; i++) {
if ((cell = (IElement)row.GetCell(i)) != null) {
if (cell is Table) {
pcell = new PdfPCell(((Table)cell).CreatePdfPTable());
}
else if (cell is Cell) {
pcell = ((Cell)cell).CreatePdfPCell();
pcell.Padding = cellpadding + cellspacing / 2f;
SimpleCell c_evt = new SimpleCell(SimpleCell.CELL);
c_evt.CloneNonPositionParameters((Cell)cell);
c_evt.Spacing = cellspacing * 2f;
pcell.CellEvent = c_evt;
}
else {
pcell = new PdfPCell();
}
pdfptable.AddCell(pcell);
}
}
}
return pdfptable;
}