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

3 posts, 1 answers
  1. Harri
    Harri avatar
    6 posts
    Member since:
    Feb 2015

    Posted 11 Mar 2015 Link to this post

    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. Harri
    Harri avatar
    6 posts
    Member since:
    Feb 2015

    Posted 12 Mar 2015 in reply to Harri Link to this post

    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;

  3. DevCraft banner
  4. Answer
    Tanya
    Admin
    Tanya avatar
    402 posts

    Posted 12 Mar 2015 Link to this post

    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.

     
Back to Top