Posted by a ceTe Software moderator
Hello,
You can achieve your requirement by adding two tables to the PDF. You will need to set the calculated X position to the second table to place it besides the first one. Below is the code sample.
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
//build first table by adding rows and columns.
Table2 table1 = new Table2(0,0,200,20);
Column2 colT1C1 = table1.Columns.Add(100);
Column2 colT1C2 = table1.Columns.Add(100);
Row2 rowT1Header = table1.Rows.Add();
Cell2 cellT1H1 = rowT1Header.Cells.Add("HEADER 1");
Cell2 cellT1H2 = rowT1Header.Cells.Add("HEADER 2");
for(int i=0;i<4;i++)
{
Row2 rowT1R1 = table1.Rows.Add();
Cell2 cellT1C1 = rowT1R1.Cells.Add("text"+(i+1));
Cell2 cellT1C2 = rowT1R1.Cells.Add("text"+(i+1));
}
table1.Height = table1.GetRequiredHeight();
page.Elements.Add(table1);
//build second table by adding rows and columns.
float xPosition = table1.X+table1.Width;
float yPosition = table1.Y;
Table2 table2 = new Table2(xPosition, yPosition, 100, 20);
Column2 colT2C1 = table2.Columns.Add(100);
Row2 rowT2Header = table2.Rows.Add();
Cell2 cellT2H1 = rowT2Header.Cells.Add("T2 HEADER 1");
for (int i = 0; i < 4; i++)
{
Row2 rowT2R1 = table2.Rows.Add();
Cell2 cellT2C1 = rowT2R1.Cells.Add("Table2 Text" + (i + 1));
}
table2.Height = table2.GetRequiredHeight();
page.Elements.Add(table2);
document.Draw(@"C:\Temp\MyDocument.pdf");
Thanks,
ceTe Software Support Team