New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Prevent the rtf, pdf and docx file download and convert the exported content to a string


Product RadEditor for ASP.NET AJAX


By design, the RadEditor ExportToPdf, ExportToRtf and ExportToDocx methods automatically convert and download the exported HTML content on the client as a file. See the solution below to learn how to obtain the converted content as a string on the server-side so that you can, for example, save it in another location as a physical file or in your database.


Here is an example of how to save the ExportOutput to a file on the server and prevent it from being sent to the client:

<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1" OnExportContent="RadEditor1_ExportContent" ContentFilters="DefaultFilters, PdfExportFilter">
<asp:Button runat="server" ID="Button1" Text="Export to PDF" OnClick="Button1_Click" />
using System;
using System.IO;
using Telerik.Web.UI;

public partial class DefaultCS : System.Web.UI.Page
    protected void RadEditor1_ExportContent(object sender, EditorExportingArgs e)
        string url = String.Format("~/{0}.pdf", RadEditor1.ExportSettings.FileName);
        string path = Server.MapPath(url);

        if (File.Exists(path))

        using (FileStream fs = File.Create(path))
            Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
            fs.Write(info, 0, info.Length);

        e.Cancel = true;

    protected void Button1_Click(object sender, EventArgs e)
Imports System.IO
Imports Telerik.Web.UI

Partial Class DefaultVB
    Inherits System.Web.UI.Page

    Protected Sub RadEditor1_ExportContent(sender As Object, e As EditorExportingArgs)
        Dim url As String = String.Format("~/{0}.pdf", RadEditor1.ExportSettings.FileName)
        Dim path As String = Server.MapPath(url)

        If File.Exists(path) Then
        End If

        Using fs As FileStream = File.Create(path)
            Dim info As [Byte]() = System.Text.Encoding.[Default].GetBytes(e.ExportOutput)
            fs.Write(info, 0, info.Length)
        End Using

        e.Cancel = True
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs)
    End Sub
End Class

See Also

In this article