Format Providers Manager
RadRichTextBox contains the DocumentFormatProvidersManager class that allows you to specify a set of format providers which can be used importing or exporting files letting the manager choose the appropriate format provider. The class also exposes methods that return all registered providers and supported file extensions.
Registering Format Providers
The DocumentFormatProvidersManager class exposes a method that allows you to register format providers. The manager has the docx, html, rtf, pdf and txt format providers registered by default through MEF. The snippet in Example 1 illustrates how to register a custom format provider. The same can be used for registering the default format providers when the MEF fails to load them automatically due to restrictions, for example.
Example 1: Register provider
You can also disable the automatic load of the default providers using the AutomaticallyLoadFormatProviders property. When it is set to
true, you should manually take care of registering the format providers you would like to use in the application.
Retrieve Registered Providers and Supported Extensions
The DocumentFormatProvidersManager class offers several approaches to retrieve the registered format providers. All the providers are available in the FormatProviders property. The class offers the GetProviderByName() static method that searches through the registered providers to find a provider with a specific name. Also, the manager exposes the GetProvderByExtension() method. Both are useful when you need to obtain one of the default format providers used by the UI and tweak it using the exposed settings.
Example 2: Modify default provider's settings
DocxFormatProvider docxFormatProvider = DocumentFormatProvidersManager.GetProviderByExtension("docx") as DocxFormatProvider; docxFormatProvider.ExportSettings.FieldResultMode = FieldDisplayMode.Code;
Dim docxFormatProvider As DocxFormatProvider = TryCast(DocumentFormatProvidersManager.GetProviderByExtension("docx"), DocxFormatProvider) docxFormatProvider.ExportSettings.FieldResultMode = FieldDisplayMode.Code
The class also contains a static method GetSupportedExtensions() that returns an IEnumeable of the currently supported file extensions.