How can I create a horizontal line similar to what is supported in Word in C# code programmatically without ever showing a RichTextBox control on screen. We are using RadDocument to output read-only report data.
Also, how can I do this without messing up the font before and after the table? The fonts get reduced in size just before and after the table.
internal static void AddHorizontalLine(Section sec, RadDocument doc, double widthInches)
{
//insert a horizontal line - table with 1 row and column - with a top border line and a table height of a few pixels
Table t = new Table() {PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, Unit.InchToDip(widthInches)) };
Border noBorder = new Border(BorderStyle.None);
t.Borders = new TableBorders(noBorder, new Border(BorderStyle.Single), noBorder, noBorder);
TableRow row = new TableRow();
row.Height = 2.0;
TableCell cell = new TableCell();
cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100.0);
Paragraph par = new Paragraph();
par.FontSize = 2;
par.Inlines.Add(new Span(" "));
cell.Blocks.Add(par);
row.Cells.Add(cell);
t.Rows.Add(row);
sec.Blocks.Add(t);
//We need to re-measure and re-layout the document after modifying the blocks, inlines, children and properties to format the output correctly. The fonts will be off if this is not done.
//doc.MeasureAndArrangeInDefaultSize(); //causes formatting problems in TOC
}
I've seen these two similar questions.
http://www.telerik.com/forums/adding-an-horizontal-line-programatically
http://www.telerik.com/forums/horizontal-line-ce12906b62c2
Also, how can I do this without messing up the font before and after the table? The fonts get reduced in size just before and after the table.
internal static void AddHorizontalLine(Section sec, RadDocument doc, double widthInches)
{
//insert a horizontal line - table with 1 row and column - with a top border line and a table height of a few pixels
Table t = new Table() {PreferredWidth = new TableWidthUnit(TableWidthUnitType.Fixed, Unit.InchToDip(widthInches)) };
Border noBorder = new Border(BorderStyle.None);
t.Borders = new TableBorders(noBorder, new Border(BorderStyle.Single), noBorder, noBorder);
TableRow row = new TableRow();
row.Height = 2.0;
TableCell cell = new TableCell();
cell.PreferredWidth = new TableWidthUnit(TableWidthUnitType.Percent, 100.0);
Paragraph par = new Paragraph();
par.FontSize = 2;
par.Inlines.Add(new Span(" "));
cell.Blocks.Add(par);
row.Cells.Add(cell);
t.Rows.Add(row);
sec.Blocks.Add(t);
//We need to re-measure and re-layout the document after modifying the blocks, inlines, children and properties to format the output correctly. The fonts will be off if this is not done.
//doc.MeasureAndArrangeInDefaultSize(); //causes formatting problems in TOC
}
I've seen these two similar questions.
http://www.telerik.com/forums/adding-an-horizontal-line-programatically
http://www.telerik.com/forums/horizontal-line-ce12906b62c2