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

Space Between RadDocument Header and Body

1 Answer 126 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Steve asked on 19 Jul 2012, 11:41 PM
I've tried to no avail to remove the space between my header and the body of my document.  Is there any way to do this?  See my attached image.
Thanks in advance,

1 Answer, 1 is accepted

Sort by
Martin Ivanov
Telerik team
answered on 24 Jul 2012, 12:30 PM
Hi Steve,

This scenario has its limitations caused by the fact that a table cannot be the first element in the document and must always be followed by a paragraph. However with some customization document with smaller space between header and body can be created using the following code:
public RadDocument CreateDocument()
    RadDocument mainDocument = new RadDocument();
    mainDocument.LayoutMode = DocumentLayoutMode.Paged;
    Section mainSection = new Section();
    Table table = new Table(4, 4);
    table.Borders = new TableBorders(new Telerik.Windows.Documents.Model.Border(2.5f, BorderStyle.Dotted, Colors.Black));
    var lastPageParagraph = CreateParagraph();
    lastPageParagraph.Inlines.Add(CreateSpan(string.Format("Number of Rows: {0}", 4)));
    mainSection.HasDifferentFirstPageHeaderFooter = true;
    mainSection.Headers.Default = new Header() { Body = this.CreateDocumentWithContent() };
    mainSection.Headers.First = new Header()
        Body = this.CreateDocumentWithContent(tableParameter =>
            TableRow additionalRow = new TableRow();
            TableCell additionalCell = new TableCell();
            additionalCell.ColumnSpan = 3;
            Paragraph additionalParagraph = CreateParagraph();
            Span additionalSpan = this.CreateSpan("text");
    return mainDocument;
private RadDocument CreateDocumentWithContent(Action<Table> additionalContent = null)
    RadDocument document = new RadDocument();
    Section section = new Section();
    section.PageMargin = new Padding(0);
    Table table = new Table();
    table.Borders = new TableBorders(new Telerik.Windows.Documents.Model.Border(2.5f, BorderStyle.Dashed, Colors.Black));
    TableRow row = new TableRow();
    TableCell first = new TableCell();
    TableCell second = new TableCell() { TextAlignment = RadTextAlignment.Center };
    TableCell third = new TableCell() { TextAlignment = RadTextAlignment.Right };
    if (additionalContent != null)
    Paragraph lastParagraph = CreateParagraph();
    lastParagraph.FontSize = 2;
    lastParagraph.SpacingAfter = 0;
    return document;
private Span CreateSpan(string text)
    return new Span(text) { FontSize = 14 };
private static Paragraph CreateParagraph()
    return new Paragraph() { SpacingAfter = 10 };

Finally assign the created RadDocument to the Document property of the RadRichTextBox to observe the result.

Don't hesitate to contact us if you have other questions.

the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question