Hi,
We have a requirement where we want to reduce or increase the space between 2 rows in a table. Can you please help me out ?
Spacing between rows
Re: Spacing between rows
Support · Jul 18, 2023Hi,
You can use CellPadding (Top and Bottom) to achieve that. Please refer to the documentation on cell padding here
.
Here is a code sample:
Document document = new Document();
Table2 table = new Table2(0, 40, 600, 690);
Column2 column1 = table.Columns.Add(100);
Column2 column2 = table.Columns.Add(100);
Column2 column3 = table.Columns.Add(100);
Column2 column4 = table.Columns.Add(100);
for (int j = 0; j < 50; j++)
{
Row2 row = table.Rows.Add(6);
for (int i = 1; i < 5; i++)
{
Cell2 cell1 = row.Cells.Add("Description");
cell1.Border.Width = 0.5f;
Cell2 cell2 = row.Cells.Add("Value");
cell2.Border.Width = 0.5f;
Cell2 cell3 = row.Cells.Add("12234");
cell3.Border.Width = 0.5f;
Cell2 cell4 = row.Cells.Add("1212222");
cell4.Border.Width = 0.5f;
}
}
table.Rows[1].CellDefault.Padding.Bottom = 10;
table.Rows[2].CellDefault.Padding.Top = 10;
do
{
Page page = new Page();
document.Pages.Add(page);
page.Elements.Add(table);
table = table.GetOverflowRows();
} while (table != null);
string outputPdf = @"C:\Temp\My12-Document.pdf";
document.Draw(outputPdf);
Thanks,
ceTe Software Support Team
Re: Spacing between rows
Forum member · Jul 18, 2023It worked. Thank you so much for your help.