New to Telerik Document ProcessingStart a free 30-day trial

Insert Field in Header

Updated on Feb 19, 2026
Product VersionProductAuthor
2020.3.1019RadWordsProcessingDimitar Karamfilov

Description

You need to add a field in the header for example to display page numbering.

Solution

This can be achieved by adding a paragraph to the header and then moving the editor position to this paragraph. Once this is done you can insert the field and move the position to another paragraph in the document.

Insert page numbering in he header

csharp

    RadFlowDocument document = new RadFlowDocument();

    var section = document.Sections.AddSection();
    var header = section.Headers.Add();

    Paragraph paragraph = header.Blocks.AddParagraph();
    paragraph.TextAlignment = Alignment.Right;

    RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
    editor.MoveToParagraphStart(paragraph);

    editor.InsertText("Page ");
    editor.InsertField("PAGE", "3");
    editor.InsertText(" of ");
    editor.InsertField("NUMPAGES", "5");

    var paragrpah2 = section.Blocks.AddParagraph();
    editor.MoveToParagraphStart(paragrpah2);

    document.UpdateFields();
    
In this article
DescriptionSolution
Not finding the help you need?
Contact Support