# RadDocument

**RadDocument** is the root element for **RadRichTextEditor's** content. It holds the collection of **Sections**  defined for the **RadRichTextEditor** content. It also allows you to configure the appearance of its child elements.

This topic will explain how you can customize the contents of the **RadDocument**.

* [Customizing a RadDocument](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/raddocument#customize-the-contents-of-raddocument)

* [Specifics](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/raddocument#specifics)

* [Adding Sections to a RadDocument](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/raddocument#adding-sections-to-raddocument)

## Customize the contents of RadDocument

**RadDocument** exposes several properties that allow you to customize the layout of the elements placed underneath it. Here is a list of them:

* **LayoutMode** - specifies whether the page should be in *Paged*, *Flow* or *FlowNoWrap* layout mode. To learn more about layout modes read [here](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/getting-started/layout-modes).

* **DefaultPageLayoutSettings** - this property is of type **PageLayoutSettings**. The **PageLayoutSettings** class exposes the following properties:

  * **Height** - represents the height of the page.

  * **Width** - represents the width of the page.

> note The **DefaultPageLayoutSettings** get applied only when Paged layout mode is used.

* **SectionDefaultPageMargin** - defines the default margin for each of the sections in the **RadDocument**. To assign different margins for each of the sections use the respective property of the **Section** class.

* **ParagraphDefaultSpacingAfter** - defines the default spacing after for each of the paragraphs in the   **RadDocument**. To assign different spacing after for each of the paragraphs use the respective property of the  **Paragraph** class.

* **ParagraphDefaultSpacingBefore** - defines the default spacing before for each of the paragraphs in the  **RadDocument**. To assign different spacing before for each of the paragraphs use the respective property of the  **Paragraph** class.

* **LineSpacing** - specifies the value for the space between the lines.

* **LineSpacingType - specifies the type of spacing:**

  * **AtLeast -** the space between the lines should be equal or greater than the value of the **LineSpacing** property.

  * **Auto -** the space between the lines is determined automatically.

  * **Exact -** the space between the lines should be equal to the value of the **LineSpacing** property.

* **ShowFormattingSymbols** - indicates whether the formatting symbols should be displayed or not.

## Specifics

The first time a **RadDocument** is shown inside a **RadRichTextEditor** in the Visual Tree, it is  measured by the framework and arranges its children. This is the moment when the layout cycle is completed, each of the document elements calculates its size and arranges its children.

As the two states of the document - measured and not measured are too different, distinct methods for manipulating the content of the document should be used before the document is measured and after the first time that it is shown in the editor.

## Adding Sections to RadDocument

As explained in the previous section, the state of the document is essential for the methods that can be used on it.

For example, you can build a **RadDocument** from scratch and add **Sections** to it in the following way:

```C#
Section section = new Section();
this.radRichTextEditor1.Document.Sections.Add(section);

```

```VB.NET
Dim section As New Section()
Me.radRichTextEditor1.Document.Sections.Add(section)

```

Splitting an already measured document into two sections at the current caret position, on the other hand, can be done by inserting a section break:

```C#
this.radRichTextEditor1.InsertSectionBreak(SectionBreakType.NextPage);

```

```VB.NET
Me.radRichTextEditor1.InsertSectionBreak(SectionBreakType.NextPage)

```

The method accept a parameter of type **SectionBreakType**. The possible values are:

* SectionBreakType.*NextPage* - the default value. The next section will start on the next page.

* SectionBreakType.*OddPage* - the next section will start on the next odd page.

* SectionBreakType.*EvenPage* - analogically, the next section will start on the next even page.

> note The distribution of the document content in sections is only visible when the document is in *Paged* layout mode. Furthermore, the sections and section breaks can be persisted in XAML, docx and RTF. If you export the document to HTML or plain text, the section breaks will be lost.

## See Also

* [Document Elements](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/overview)

* [Section](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/section)

* [Paragraph](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/paragraph)

* [Span](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/span)

* [Inline Image](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/document-elements/inline-image)

* [Hyperlink](https://www.telerik.com/products/winforms/documentation/controls/richtexteditor/features/hyperlink)
