Earlier this year I wrote a blog about how the PDF export functionality of Telerik’s ASP.NET rich text Editor can be easily improved by using the PDF document provider implemented in the RadContols for WPF suite. Since we recently received questions about some missing features in the editor’s RTF support, I decided to implement a solution extending the default functionality. It is similar to the one explained in the previous article, because it leverages the HTML and RTF document providers contained in the same XAML suite.
You can easily get the additional functionality provided in the XAML document providers by just creating a class, which implements the RadEditorExportTemplate abstract class defined in the Telerik.Web.UI.Editor.Export namespace of the Telerik.Web.UI assembly. Then you need to use the SetRtfExportTemplate RadEditor method to inject an instance of the created class in the editor’s export to RTF functionality.
Let’s start with an ASP.NET Empty Web Application for .NET Framework 4.5 project named RadEditorRtfExportEnhancement
Then I will add references to the latest 2013 Q2 Telerik assemblies, which I need to use. These are the Telerik.Web.UI from RadControls for ASP.NET AJAX and Telerik.Windows.Controls, Telerik.Windows.Data, Telerik.Windows.Documents, Telerik.Windows.Documents.FormatProviders.Html, Telerik.Windows.Documents.FormatProviders.Rtf, Telerik.Windows.Zip assemblies, which are part of our WPF suite.
Next I will add a Web Form page named Default.aspx, containing the following code:Markup
The code behind looks like this:C#
As you can see, RadEditor's content is exported in the BtnExportToRtf_Click handler and in the Page_Load method the editor is configured to use the custom TelerikRtfExportTemplate export template class. This is done by the SetRtfExportTemplate method.
The only thing left to be done is the implementation of the mentioned above class. More information about the export template design can be found in my previous post Using an external library for the export to PDF functionality in Telerik’s ASP.NET Editor and in the "Using an external HTML to PDF conversion library" section of the following online help article Export to PDF.Here is the source code of the class:
By creating a simple example I showed how an external tool can be integrated in the RadEditor’s export to RTF functionality. In this case it was a library created by Telerik, so owning more than one of the Telerik’s controls suites or even the DevCraft bundle is totally worth it. You can download the source code of this sample here and use it directly in your projects.
Now if you experience any problems with RadEditor’s default RTF support, we encourage you to take advantage of the provided solution. Feel free to comment and even share other cases when different RadControls suites can be used in collaboration.
Stanimir Patarinski is currently a senior software developer at Telerik Corp. He joined the company in the end of 2008 and his experience is centered on the ASP.NET AJAX products from Telerik, particularly the RadEditor control. He is an MCPD certified Web, SharePoint and Azure developer and has extensive knowledge about the integration of RadControls in third-party applications including SharePoint 2007, 2010, 2013.
Subscribe to be the first to get our expert-written articles and tutorials for developers!
All fields are required