Available for: UI for ASP.NET MVC | UI for ASP.NET AJAX | UI for Blazor | UI for WPF | UI for WinForms | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial

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 properties which allow you to customize the way content is presented. The following properties are available for change:

  • DocumentInfo: This property enables you to set and obtain metadata information for the document file. It is of type DocumentInfo and allows you get and set the Author, Title, Subject, Keywords and Description.

  • ViewType: An enumeration which specifies how the document should be laid out when displayed. It depends on the application with which the document is opened after it has been created whether this property is respected.

  • Theme: Specifies the theme which is applied to the document. The document theme enables you to specify colors, fonts and a variety of graphic effects which affect the look of the whole document. More information is available here.

  • StyleRepository: Represents the document' StyleRepository. The repository allows to add, remove or enumerate the styles of the document.

  • DefaultStyle: The default styles that are used for Paragraph and Run elements. More information on default styles is available here.

  • HasDifferentEvenOddPageHeadersFooters: Gets or sets whether pages in this document should 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 that are used when the document is protected. More information is available here.

  • DefaultTabStopWidth: The distance between automatic TabStops.

Operating with a RadFlowDocument

There are different actions which you can execute 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 could create a section by passing to its constructor the document it should be 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 pass the source document as a parameter to it:

Example 4: Merge documents

document.Merge(sourceDocument); 

Additionally, you have the opportunity to specify the MergeOptions which control the merge operation:

  • ConflictingStylesResolutionMode: An enumeration specifying the mode used for resolving conflicts between styles with same IDs. The possible values for ConflictingStylesResolutionMode are:

    • 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 which allows you to update all fields in the document. More information about fields is available here.

The snippet from Example 6 shows how all fields in a document can be updated simultaneously.

Example 6: Update all fields in a document

document.UpdateFields(); 

See Also

In this article