New to Telerik Document Processing? Start a free 30-day trial

RadFixedDocumentEditor

Updated on Nov 5, 2026

The RadFixedDocumentEditor class in PdfProcessing lets you create a RadFixedDocument in a flow-like way and insert elements one after another. During layout, the editor calculates element size automatically and moves content to new pages when needed.

Creating RadFixedDocumentEditor

Example 1 demonstrates how to create a RadFixedDocumentEditor instance.

Example 1: Create a RadFixedDocumentEditor

C#
RadFixedDocument radFixedDocument = new RadFixedDocument();
RadFixedDocumentEditor radFixedDocumentEditor = new RadFixedDocumentEditor(radFixedDocument);

//Use RadFixedDocumentEditor...

radFixedDocumentEditor.Dispose();

RadFixedDocumentEditor implements IDisposable, so you must dispose it after you finish building the document. Otherwise, some content may not be finalized and may not appear in the exported PDF file.

Sections

A Section is a sequence of RadFixedPage instances that share the same properties.

SectionProperties

The section properties control the page size, margins, and orientation of the pages in a section. The following list includes the available properties:

  • PageSize: The size of the pages in the section.

  • PageMargins: The page margins.

  • PageRotation: The page rotation. This enum supports the following values:

    • Rotate0: The page is not rotated. This is the default value.
    • Rotate90: The page is rotated to 90°.
    • Rotate180: The page is rotated to 180°.
    • Rotate270: The page is rotated to 270°.

Example 2: Set section properties

C#
radFixedDocumentEditor.SectionProperties.PageSize = new Size(100, 100);
radFixedDocumentEditor.SectionProperties.PageRotation = Telerik.Documents.Fixed.Model.Data.Rotation.Rotate90;

Starting New Section

The first section starts as soon as you insert content in the editor. If you set the section properties before you insert any content, the automatically created first section uses these values.

Add another section with the InsertSectionBreak() method, as shown in Example 3.

Example 3: Start a section

C#
radFixedDocumentEditor.InsertSectionBreak();

To change the properties of the next section, set them before you insert the section break. New values apply only to newly created sections.

Starting New Page

All pages that have the same SectionProperties are part of the current section. To start a new page, use the following code:

Example 4: Start a new page

C#
radFixedDocumentEditor.InsertPageBreak();

Paragraphs

Paragraphs contain flowing inline content such as text and images.

ParagraphProperties

Like sections, paragraphs have their own properties that control appearance.

  • SpacingBefore: The spacing before the paragraph.

  • SpacingAfter: The spacing after the paragraph.

  • LineSpacing: The spacing between lines. Defaults to 1.15. When LineSpacingType is Auto, this acts as a line height multiplier. When LineSpacingType is Exact or AtLeast, this specifies the line height in Device Independent Pixels (DIPs).

  • LineSpacingType: Specifies how to interpret the line spacing using the HeightType enumeration (Auto, Exact, AtLeast). Defaults to Auto.

  • FirstLineIndent: The indent for the first line.

  • LeftIndent: The left indent.

  • RightIndent: The right indent.

  • BackgroundColor: The background color.

  • HorizontalAlignment: The horizontal alignment of the content.

  • ListId: The ID of the list that the paragraph belongs to. If the value is null, the paragraph does not belong to a list.

  • ListLevel: The list level the paragraph belongs to.

Example 5: Set paragraph properties

C#
radFixedDocumentEditor.ParagraphProperties.SpacingAfter = 10;
radFixedDocumentEditor.ParagraphProperties.LineSpacingType = HeightType.Auto;
radFixedDocumentEditor.ParagraphProperties.BackgroundColor = new RgbColor(0, 100, 0);
radFixedDocumentEditor.ParagraphProperties.HorizontalAlignment = Telerik.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;

Starting New Paragraph

The first paragraph starts as soon as you insert content in the editor. If you set paragraph properties before you insert content, the automatically created first paragraph uses these values.

To start a new paragraph, use the code in Example 6.

Example 6: Start a paragraph

C#
radFixedDocumentEditor.InsertParagraph();

This method starts a new paragraph and uses the current paragraph properties. Property changes do not apply until a new paragraph starts.

Inlines

A paragraph consists of two inline types: runs and images.

Runs

A Run represents a sequence of characters that share the same properties.

Example 7: Set character properties

The following character properties control the appearance of runs:

  • FontSize: The font size.

  • Font: The font.

  • ForegroundColor: The foreground color.

  • HighlightColor: The highlight color.

  • BaselineAlignment: Describes how the baseline for a text-based element is positioned on the vertical axis, relative to the established baseline for text.

    • Baseline: A baseline that is aligned at the actual baseline of the containing box.
    • Subscript: A baseline that is aligned at the subscript position of the containing box.
    • Superscript: A baseline that is aligned at the superscript position of the containing box.
  • UnderlinePattern: The underline pattern. Two patterns are supported.

    • None: There is no underline. This is the default value.
    • Single: The underline is a single line.
  • UnderlineColor: The color of the underline.

  • StrikethroughPattern: The strikethrough pattern. Two patterns are supported.

    • None: There is no strikethrough. This is the default value.
    • Single: The strikethrough is a single line.
  • StrikethroughColor: The color of the strikethrough.

Setting CharacterProperties

C#
radFixedDocumentEditor.CharacterProperties.FontSize = 12;
radFixedDocumentEditor.CharacterProperties.Font = FontsRepository.Courier;
radFixedDocumentEditor.CharacterProperties.HighlightColor = new RgbColor(10, 100, 80);
radFixedDocumentEditor.CharacterProperties.BaselineAlignment = Telerik.Documents.Fixed.Model.Editing.Flow.BaselineAlignment.Subscript;
radFixedDocumentEditor.CharacterProperties.UnderlinePattern = Telerik.Documents.Fixed.Model.Editing.Flow.UnderlinePattern.Single;

For the character properties to take effect, set them before you insert the run.

In .NET Standard/.NET (Target OS: None) environments, fonts beyond the 14 standard ones require a FontsProvider implementation to be resolved correctly.

Inserting a Run

Several overloads insert a run. The code snippet in Example 8 inserts runs with a specific font family, style, and weight.

Example 8: Insert a run

C#
radFixedDocumentEditor.InsertRun("text");
radFixedDocumentEditor.InsertRun(new FontFamily("Helvetica"), "text");

The \r and \n characters do not create a new line when you insert text in a PDF document. To create multiline text, split the text and insert a line break explicitly.

The code in Example 9 inserts a new run and a line break after it.

Example 9: Insert a run and a line break

C#
radFixedDocumentEditor.InsertLine("Line of text");

Images

An image inline is a combination of an ImageSource object and its desired size.

Inserting an Image

You can insert an image inline using one of the following methods:

Example 10: Insert an image

C#
ImageSource imageSource = new ImageSource(new FileStream("image.jpeg", FileMode.Open));
radFixedDocumentEditor.InsertImageInline(imageSource);
radFixedDocumentEditor.InsertImageInline(imageSource, new Size(100, 100));

Tables

The Table class implements the IBlockElement interface, so you can insert a table as a new block in the document. Insert it with the InsertTable() method, as shown in Example 11. RadFixedDocumentEditor handles positioning, measuring, and splitting the table across pages.

Example 11: Insert a table

C#
Table table = new Table();
TableRow firstRow = table.Rows.AddTableRow();
firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("cellText");

radFixedDocumentEditor.InsertTable(table);

For more detailed information on tables, see the Table documentation article.

Block Elements

The IBlockElement interface lets you draw and split block content across pages. The Block and Table classes implement this interface. Add a block element instance with RadFixedDocumentEditor by using the InsertBlock() method, as shown in Example 12.

Example 12: Insert a block element

C#
Block block = new Block();
block.InsertText("Text");

radFixedDocumentEditor.InsertBlock(block);

Lists

You can insert list items with RadFixedDocumentEditor. First, add a List to the editor ListCollection through the Lists property. Then, each time you want to add a list item, set the ListId and ListLevel values through RadFixedDocumentEditor.ParagraphProperties. Each new paragraph becomes a new list item.

The following code snippet shows how to add a new list to the RadFixedDocumentEditor ListCollection and then insert a paragraph with the corresponding list properties:

Example 13: Insert a list

C#
List list = radFixedDocumentEditor.Lists.AddList(ListTemplateType.NumberedDefault);
radFixedDocumentEditor.ParagraphProperties.ListId = list.Id;
radFixedDocumentEditor.ParagraphProperties.ListLevel = 0;
radFixedDocumentEditor.InsertParagraph();

More detailed information about lists is available in the list article.

Forms

With RadFixedDocumentEditor, you can insert a form (Form XObject) element.

Example 14: Insert a form

C#
radFixedDocumentEditor.InsertFormInline(formSource);

There is an additional overload of InsertFormInline() that lets you pass the size to use for the form.

For more information about creating forms, see the Form and FormSource articles.

Headers and Footers

Use RadFixedDocumentEditor to add headers and footers that repeat on generated pages. The editor measures their height and reserves space for body content.

Creating Headers and Footers

Call AddHeader() or AddFooter() to set the current section's default content. Use AddFirstPageHeader(), AddFirstPageFooter(), AddEvenPageHeader(), and AddEvenPageFooter() for alternate content. The following example sets each variant and adds text across multiple pages:

Example 15: Configure Headers and Footers

csharp
using Telerik.Documents.Fixed.Model;
using Telerik.Documents.Fixed.Model.Editing;

RadFixedDocument document = new RadFixedDocument();

using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))
{
    editor.SectionProperties.HeaderTopMargin = 36;
    editor.SectionProperties.FooterBottomMargin = 36;

    editor.AddHeader().Blocks.AddBlock().InsertText("Default header");
    editor.AddFooter().Blocks.AddBlock().InsertText("Default footer");

    editor.SectionProperties.DifferentFirstPageHeaderFooter = true;
    editor.AddFirstPageHeader().Blocks.AddBlock().InsertText("First-page header");
    editor.AddFirstPageFooter().Blocks.AddBlock().InsertText("First-page footer");

    editor.DifferentOddAndEvenPages = true;
    editor.AddEvenPageHeader().Blocks.AddBlock().InsertText("Even-page header");
    editor.AddEvenPageFooter().Blocks.AddBlock().InsertText("Even-page footer");

    const int paragraphCount = 60;
    for (int paragraphIndex = 0; paragraphIndex < paragraphCount; paragraphIndex++)
    {
        editor.InsertParagraph();
        editor.InsertRun("This paragraph demonstrates repeated headers and footers across generated pages.");
    }
}

Each method returns a HeaderFooter object and assigns it to the matching SectionProperties property. Add Block or Table elements to the returned object's Blocks collection.

Choosing Page Variants

SectionProperties stores default content in Header and Footer, first-page variants in FirstPageHeader and FirstPageFooter, and even-page variants in EvenPageHeader and EvenPageFooter. Set these options to choose page variants:

  • First-page variants: Set SectionProperties.DifferentFirstPageHeaderFooter to true to use alternate content on each section's first page.
  • Even-page variants: Set RadFixedDocumentEditor.DifferentOddAndEvenPages to true to use alternate content on even-numbered pages.
  • Default variants: The editor uses default content on odd pages and when alternate variants are not enabled. If an alternate variant is enabled but unset, the editor renders no content and does not fall back.
  • Section breaks: Set replacement variants before InsertSectionBreak() to pass them to the new section. The new section reuses the same HeaderFooter objects by reference. The editor leaves existing pages unchanged.

Controlling Layout and Accessibility

The editor applies these layout and accessibility rules:

  • Margins: Use SectionProperties.HeaderTopMargin and SectionProperties.FooterBottomMargin to set the distance from each page edge to its header or footer. Both values use device-independent pixels (DIPs) and default to 48. The editor compares each page margin with the configured edge distance plus measured content height, then uses the greater value. It leaves PageSize and PageMargins unchanged.
  • Content limits: Each header or footer can contain only Block or Table elements and cannot exceed 40% of the page height. The editor throws InvalidOperationException if content uses an unsupported element, cannot be measured, produces an invalid height, or exceeds the limit. It also throws InvalidOperationException if reserved areas leave no room for body content.
  • Tagged PDF: During tagged PDF export, the editor marks headers and footers as pagination artifacts outside the structure tree. It tags body content normally.

See Also