This code creates a document with 3 tables of increasing height. However, when measured each has the same height. How can a table's height be measured in a way that will account for text that wraps onto multiple lines?
Thanks,
Tim
protected void AddTable(string header, string text, RadFixedDocumentEditor editor)
{
Table table = new Table();
RgbColor bordersColor = new RgbColor(149, 179, 215);
Border border = new Border(1, Telerik.Windows.Documents.Fixed.Model.Editing.BorderStyle.Single, bordersColor);
table.Borders = new TableBorders(border);
table.DefaultCellProperties.Borders = new TableCellBorders(border, border, border, border);
table.DefaultCellProperties.Padding = new Thickness(5);
table.Margin = new Thickness(10);
TableRow tableRow = table.Rows.AddTableRow();
TableCell tableCell = tableRow.Cells.AddTableCell();
tableCell.Borders = new TableCellBorders(new Border(BorderStyle.None));
Block block = tableCell.Blocks.AddBlock();
block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
block.InsertText(header);
tableRow = table.Rows.AddTableRow();
tableCell = tableRow.Cells.AddTableCell();
block = tableCell.Blocks.AddBlock();
block.InsertText(text);
double th = table.Measure().Height;
editor.InsertTable(table);
block = new Block();
block.InsertText(th.ToString());
editor.InsertBlock(block);
}
protected void btnTest_Click(object sender, EventArgs e)
{
RadFixedDocument radFixedDocument = new RadFixedDocument();
using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(radFixedDocument))
{
AddTable("Table 1", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore", editor);
AddTable("Table 2", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", editor);
AddTable("Table 3", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", editor);
}
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
using (FileStream fileStream = File.Open(@"C:\Temp\Test.pdf", FileMode.Create))
{
pdfFormatProvider.Export(radFixedDocument, fileStream);
}
}