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.
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.
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.
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.
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.
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:
Section section = new Section(); this.radRichTextEditor1.Document.Sections.Add(section);
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:
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.
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.