Hi all,
This is a fragment from my code where I use tables in a RadFlowDocument to list some values. This all works fine for me, except one thing: between the text in a cell en the bottom border of that cell is some white space I can't get rid of. I want the bottom border of the cell to have the same distance to the text in the cell as between the text and the top border (border color set to blue for debugging..)
Tried playing with the row Height, cell padding, etc., but that doesn't change anything.
What am I missing?
var doc = new RadFlowDocument();
var tableStyle = new Style("TableStyle", StyleType.Table);
tableStyle.TableProperties.Borders.LocalValue = new TableBorders(new Border(1, BorderStyle.Single, new ThemableColor(Colors.Blue)));
tableStyle.TableProperties.Alignment.LocalValue = Alignment.Left;
tableStyle.TableCellProperties.VerticalAlignment.LocalValue = VerticalAlignment.Top;
tableStyle.TableCellProperties.Padding.LocalValue = new Padding(0, 0, 0, 0);
tableStyle.TableRowProperties.TableCellSpacing.LocalValue = 0;
tableStyle.CharacterProperties.FontSize.LocalValue = 12;
doc.StyleRepository.Add(tableStyle);
var section = new Section(doc)
{
PageMargins = new Padding(50, 50, 50, 50),
PageNumberingSettings =
{
StartingPageNumber = 1,
}
};
doc.Sections.Add(section);
var paragraph = new Paragraph(doc);
section.Blocks.Add(paragraph);
Table table = new Table(doc, 0, 2)// 0 rows, 2 columns.
{
LayoutType = TableLayoutType.FixedWidth,
PreferredWidth = new TableWidthUnit(700),
StyleId = "TableStyle"
};
// add 2 rows with 2 cells
TableRow row = table.Rows.AddTableRow();
TableCell cell = row.Cells.AddTableCell();
cell.PreferredWidth = new TableWidthUnit(100);
paragraph = cell.Blocks.AddParagraph();
paragraph.Inlines.AddRun($"Cell R1C1");
cell = row.Cells.AddTableCell();
cell.PreferredWidth = new TableWidthUnit(600);
paragraph = cell.Blocks.AddParagraph();
paragraph.Inlines.AddRun("Cell R1C2");
cell = row.Cells.AddTableCell();
cell.PreferredWidth = new TableWidthUnit(100);
paragraph = cell.Blocks.AddParagraph();
paragraph.Inlines.AddRun($"Cell R2C1");
cell = row.Cells.AddTableCell();
cell.PreferredWidth = new TableWidthUnit(600);
paragraph = cell.Blocks.AddParagraph();
paragraph.Inlines.AddRun("Cell R2C2");
Kind regards,
Kees Alderliesten
Hi Kees,
I built the provided code snippet by adding: "section.Blocks.Add(table);". After that, I have set the table row height like this:
row.Height = new TableRowHeight(HeightType.Exact, Telerik.Windows.Documents.Media.Unit.InchToDip(0.2));
Finally, I have exported the document to *.docx and the result has equal space from the top and bottom of the row:
Am I missing something from the setup? I am looking forward to your reply.
Hi Vladislav,
The Add(table) I forgot to copy/paste.
I'm exporting to PDF, but did tested it now with docx and see the same whitespace.
The only difference between my code above and my real code is that there is a full-width image above the table.
For the sake of brevity, I omitted that.
I will extract my code to a separate test-project and if I can reproduce it there I will post that project here.
Thanks for looking into it!
Kind regards,
Kees Alderliesten