This is a migrated thread and some comments may be shown as answers.

Change to new components, problems to define header and footer height and also some table row height problems

2 Answers 39 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Harri
Top achievements
Rank 1
Harri asked on 11 Mar 2015, 09:34 AM
I was using Telerik 2013 Q1 components and now updated to 2015 Q1. In old I did document in code behind and all looked good.

Header and footer set code:
section.Footers.Default = new Footer() { Body = docFooter };
section.Headers.Default = new Header() { Body = docHeader };
section.HeaderTopMargin = 20;
section.FooterBottomMargin = 10

But now this doesn't work anymore and there are lot of lost space (see pictures).

There are also some problems with table row height. See picture Header, there are tables created same way in header and body but body has some extra on those rows.

Header table to docHeader variable:
Table table = new Table();
TableRow headerRow1 = new TableRow();
headerRow1.Cells.Add(CreateCell(" ", cell1Width, 12, false, RadTextAlignment.Left, Colors.Black, 1));
headerRow1.Cells.Add(CreateCell(" ", cell2Width, 12, false, RadTextAlignment.Left, Colors.Black, 1));
headerRow1.Cells.Add(CreateCell(" ", cell3Width, 12, false, RadTextAlignment.Right, Colors.Black, 1));
headerRow1.Cells.Add(CreateCell("Sivu", cell4Width, 10, false, RadTextAlignment.Right, Colors.Black, 1));
TableCell pageNumCell = CreateCell(" ", cell5Width, 10, false, RadTextAlignment.Right, Colors.Black, 1);
headerRow1.Cells.Add(pageNumCell);
 
table.Rows.Add(headerRow1);
 
TableRow headerRow2 = new TableRow();
headerRow2.Cells.Add(CreateCell(" ", cell1Width, 12, false, RadTextAlignment.Left, Colors.Black, 1));
headerRow2.Cells.Add(CreateCell("Lähettäjä", cell2Width, 10, false, RadTextAlignment.Left, Colors.Black, 1));
headerRow2.Cells.Add(CreateCell("Itselaskutus", cell3Width, 12, true, RadTextAlignment.Right, Colors.Black, 1));
headerRow2.Cells.Add(CreateCell("Maksaja", cell4Width, 10, false, RadTextAlignment.Left, Colors.Black, 1));
headerRow2.Cells.Add(CreateCell(" ", cell5Width, 10, false, RadTextAlignment.Right, Colors.Black, 1));
table.Rows.Add(headerRow2);
// and so on...

And Body document stuff:
Table tableRecBilInfo = new Table();
//otsikot
#region Row1
tableRecBilInfoRow = new TableRow();
tableRecBilInfoRow.Height = 20;
tableRecBilInfoCell01 = CreateCell(" ", RecBilInfoCell01Width, 10, false, RadTextAlignment.Left, Colors.Black);
tableRecBilInfoCell01.Borders = new TableCellBorders(
    new Telerik.Windows.Documents.Model.Border(1, BorderStyle.Single, Colors.Black),
    new Telerik.Windows.Documents.Model.Border(1, BorderStyle.Single, Colors.Black),
    new Telerik.Windows.Documents.Model.Border(0, BorderStyle.Single, Colors.Black),
    new Telerik.Windows.Documents.Model.Border(0, BorderStyle.Single, Colors.Black)
    );
tableRecBilInfoRow.Cells.Add(tableRecBilInfoCell01);
 
tableRecBilInfoCell02 = CreateCell("Vastaanottaja", RecBilInfoCell02Width + RecBilInfoCell03Width, 10, false, RadTextAlignment.Left, Colors.Black, 2);
tableRecBilInfoCell02.Borders = new TableCellBorders(
    new Telerik.Windows.Documents.Model.Border(0, BorderStyle.Single, Colors.Black),
    new Telerik.Windows.Documents.Model.Border(1, BorderStyle.Single, Colors.Black),
    new Telerik.Windows.Documents.Model.Border(0, BorderStyle.Single, Colors.Black),
    new Telerik.Windows.Documents.Model.Border(0, BorderStyle.Single, Colors.Black)
    );
tableRecBilInfoRow.Cells.Add(tableRecBilInfoCell02);
// and so on ...



How do I set header and footer to specific heigth? And how to set tablerow height so that it is working also in body?

/Harri

2 Answers, 1 is accepted

Sort by
0
Harri
Top achievements
Rank 1
answered on 12 Mar 2015, 10:00 AM
Solutions founded.

Header and footer creation added:
section.Headers.Default.Body.ParagraphDefaultSpacingAfter = 0;
section.Headers.Default.Body.ParagraphDefaultSpacingBefore = 0;
section.Footers.Default.Body.ParagraphDefaultSpacingAfter = 0;
section.Footers.Default.Body.ParagraphDefaultSpacingBefore = 0;


And that Body problem, added in that CreateCell function two lines (there was created paragraph inside that cell):
paragraph.SpacingAfter = 0;
paragraph.SpacingBefore = 0;

0
Accepted
Tanya
Telerik team
answered on 12 Mar 2015, 04:57 PM
Hello Harri,

I am glad to hear that you managed to resolve the issue.

Just to shed some light on this behavior, in versions before Q1 2015 when inserting a table, a paragraph must be inserted before it. From our last release this paragraph is not mandatory and I can suggest you to check and remove the unused paragraphs in order to save space and unneeded code. The RadDocumentEditor API exposes a method InsertTable which you could use to insert table without a paragraph before it:
var editor = new RadDocumentEditor(this.radRichTextBox.Document);
editor.InsertTable(3, 4, false);

The header/footer height is calculated depending on the margins and content, so there is no property that directly controls that. You can set the margins to 0 using the RadDocumentEditor's methods:
editor.ChangeSectionFooterBottomMargin(0);
editor.ChangeSectionHeaderTopMargin(0);

Regarding the last question, the Row class has a property for setting its height:
TableRow row = table.Rows.First;
row.Height = 50;

Let me know if you need any further assistance.

Regards,
Tanya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
RichTextBox
Asked by
Harri
Top achievements
Rank 1
Answers by
Harri
Top achievements
Rank 1
Tanya
Telerik team
Share this question
or