The OnExportContent event fires just before the content from the Telerik Editor is exported. It provides access to the generated output, so that it could be used or modified upon further application requirements.
The event handler receives two arguments:
Sender–the RadEditor instance that raised the event.
Event arguments–an object of type Telerik.Web.UI.EditorExportingArgs exposes the string ExportOutput property, the Telerik.Web.UI.ExportType property and a Boolean Cancel property with which you can cancel the sending of the file to the client (by default is set to false).
Example 1: How to save the ExportOutput to a file on the server and prevent it from being sent to the client.
ASP.NET
<telerik:RadEditorRenderMode="Lightweight"runat="server"ID="RadEditor1"OnExportContent="RadEditor1_ExportContent"ContentFilters="DefaultFilters, PdfExportFilter"></telerik:RadEditor><asp:Buttonrunat="server"ID="Button1"Text="Export to PDF"OnClick="Button1_Click"/>
ImportsSystem.IO
Imports Telerik.Web.UI
PartialClass DefaultVB
InheritsSystem.Web.UI.Page
ProtectedSub RadEditor1_ExportContent(sender AsObject, e As EditorExportingArgs)Dim url AsString=String.Format("~/{0}.pdf", RadEditor1.ExportSettings.FileName)Dim path AsString= Server.MapPath(url)If File.Exists(path)Then
File.Delete(path)EndIfUsing fs As FileStream = File.Create(path)Dim info As [Byte]()=System.Text.Encoding.[Default].GetBytes(e.ExportOutput)
fs.Write(info,0, info.Length)EndUsing
e.Cancel =TrueEndSubProtectedSub Button1_Click(sender AsObject, e As EventArgs)
RadEditor1.ExportToPdf()EndSubEndClass
Example 2: Dynamically adding header and footer elements to the exported document in the OnExportContent event.
ASP.NET
<telerik:RadEditorRenderMode="Lightweight"runat="server"ID="RadEditor1"OnExportContent="RadEditor1_ExportContent"ContentFilters="DefaultFilters, PdfExportFilter"></telerik:RadEditor><asp:Buttonrunat="server"ID="Button1"Text="Export to DOCX"OnClick="Button1_Click"/>