RadFlowDocument
RadFlowDocument hosts flow document content and is the root element in the document elements tree. It holds a collection of Section elements.
Inserting and Modifying a RadFlowDocument
The code from Example 1 shows how you can create a new RadFlowDocument.
Example 1: Create RadFlowDocument
RadFlowDocument document = new RadFlowDocument();
RadFlowDocument exposes the following properties to customize the way content is presented:
| Property | Description |
|---|---|
DocumentInfo | Enables you to set and obtain metadata for the document file. Of type DocumentInfo, it allows you to get and set Author, Title, Subject, Keywords, and Description. |
ViewType | An enumeration that specifies how the document should be laid out when displayed. Whether this property is respected depends on the application used to open the document. |
Theme | Specifies the theme applied to the document. The document theme enables you to specify colors, fonts, and graphic effects that affect the look of the whole document. More information is available in the Document Themes article. |
StyleRepository | Represents the document's StyleRepository. The repository allows you to add, remove, or enumerate the styles of the document. |
DefaultStyle | The default styles used for Paragraph and Run elements. More information on default styles is available in the Styles article. |
HasDifferentEvenOddPageHeadersFooters | Gets or sets whether pages in this document have different headers and footers for even and odd pages. |
ListCollection | Represents the collection of Lists in the document. |
CommentCollection | Represents the collection of Comments in the document. |
ProtectionSettings | Corresponds to the settings used when the document is protected. More information is available in the PermissionRange article. |
DefaultTabStopWidth | The distance between automatic TabStops. |
Operating with a RadFlowDocument
You can execute different actions with the help of the RadFlowDocument element.
Adding Sections
You can create a RadFlowDocument from scratch and add Sections to it as follows:
Example 2: Add a Section to a RadFlowDocument
RadFlowDocument document = new RadFlowDocument();
document.Sections.AddSection();
The Sections property of the document is of type SectionCollection and allows you to add sections to the document.
Alternatively, you can create a section by passing to its constructor the document it is associated with.
Example 3: Create a section
Section section = new Section(document);
Merge with Another Document
You can merge a RadFlowDocument within another document by using the Merge() method and passing the source document as a parameter:
Example 4: Merge documents
document.Merge(sourceDocument);
You can also specify the MergeOptions that control the merge operation:
-
ConflictingStylesResolutionMode: An enumeration specifying the mode used for resolving conflicts between styles with the same IDs. The possible values forConflictingStylesResolutionModeare:UseTargetStyle: If a conflict between styles with the same IDs appears, the style of the target document is used.RenameSourceStyle: If a conflict between styles with the same IDs appears, the style of the source document is renamed and used.
Example 5: Merge documents using MergeOptions
MergeOptions mergeOptions = new MergeOptions();
mergeOptions.ConflictingStylesResolutionMode = ConflictingStylesResolutionMode.RenameSourceStyle;
document.Merge(sourceDocument, mergeOptions);
Update Fields
RadFlowDocument exposes an UpdateFields() method that allows you to update all fields in the document. More information about fields is available in the Fields article.
The snippet from Example 6 shows how to update all fields in a document simultaneously.
Example 6: Update all fields in a document
document.UpdateFields();