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

Custom text in header per page

1 Answer 55 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Leonardo
Top achievements
Rank 1
Leonardo asked on 09 May 2012, 02:44 PM
Is possible add text (field) in header where its content is different for each page?

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 14 May 2012, 09:34 AM
Hi Leonardo,
Actually, headers and footers are properties of the section. You can have up to three different headers/footers per section - for odd, even and first page:
Section section = new Section();
RadDocument document = new RadDocument();
document.Sections.Add(section);
  
// this is the default header
section.Headers.Default = new Header()
{
    Body = this.CreateHeaderFooterDocument("Default Page Header")
};
  
section.Headers.Even = new Header()
{
    Body = this.CreateHeaderFooterDocument("Even Page Header")
};
// this must be set in order even headers/footers to be visible
document.HasDifferentEvenAndOddHeadersFooters = true;
  
section.Headers.First = new Header()
{
    Body = this.CreateHeaderFooterDocument("First Page Header")
};
// this must be set in order first page header/footer to be visible
section.HasDifferentFirstPageHeaderFooter = true;
  
// these are some other properties that control headers/footers presentation
section.HeaderTopMargin = 32;
section.FooterBottomMargin = 32;
  
// 2 pages inserted here
document.InsertPageBreak();
document.InsertPageBreak();
  
this.radRichTextBox.Document = document;
private RadDocument CreateHeaderFooterDocument(string text)
{
    Span span = new Span(text);
  
    Paragraph paragraph = new Paragraph();
    paragraph.Inlines.Add(span);
  
    Section section = new Section();
    section.Blocks.Add(paragraph);
  
    RadDocument document = new RadDocument();
    document.Sections.Add(section);
  
    return document;
}
You can also insert PageField in the headers/footers, and they will be evaluated to the current page number.

Kind regards,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Leonardo
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or