Using RtfFormatProvider
RtfFormatProvider makes it easy to import and export RadDocument to/from RTF format, preserving the entire document structure and formatting.
All you have to do in order to use RtfFormatProvider is to add references to:
- Telerik.Windows.Documents.FormatProviders.Rtf.dll
Import
In order to import an RTF document, you need to use the Import() method of RtfFormatProvider.
The code from Example 1 shows how to use RtfFormatProvider to import an RTF document from a file.
Example 1: Import document from a file
Example 2: Import document from a string
Export
In order to export a document to RTF, you need to use the Export() method of RtfFormatProvider.
Example 3 shows how to use RtfFormatProvider to export RadDocument to a file.
Example 3: Export a document to a file
Example 4: Export a document to a string
However, the format providers cannot be used in XAML and you have to implement a logic that will call their Import() and Export() methods. This is something that you might not want to be concerned with when using RadRichTextBox in a data bound scenarios. For such cases, the DataProvider classes are used. They wrap the FormatProviders' functionality and allow its usage in XAML.