Import and Export of Documents
As of the R1 2017 release, the Telerik UI Editor for ASP.NET MVC enables you to import and export various types of documents through the dedicated export assembly. In current releases, use the Telerik.Export.Core NuGet package.
Along with the server-side integration of the Telerik Document Processing suite, the new ExportAs and Import tools which utilize the import and export functionality are available.

Requirements
The import and export capabilities are bundled as part of the UI for ASP.NET MVC suite. You can get the required assemblies from the telerik.ui.for.aspnetmvc.<version>.zip archive that contains a Kendo.MVC.Export folder with the assemblies for both .NET 4.0 and .NET 4.5 versions. For product versions after Q2 2025, use the Telerik.Core.Export NuGet package.
To start using the import and export functionality:
- Add a reference in your project to the
Telerik.Export.Coreassembly, or install theTelerik.Export.CoreNuGet package. - Add references in your project to the required Telerik Document Processing libraries.
Exporting Content from the Editor
-
Add the
ExportAstool.Razor@(Html.Kendo().Editor() .Name("Editor") .Tools(tools => tools .ExportAs() ) )Alternatively, you can refine the options by configuring the
ExportAstool.Razor@(Html.Kendo().Editor() .Name("Editor") .Tools(tools => tools .ExportAs(export => export .Add("DOCX", "docx") .Add("RTF", "rtf") .Add("PDF", "pdf") .Add("HTML", "html") .Add("TXT", "txt") ) ) ) -
To enable the tool to contact the server and export a file, configure the
Proxymethod and, optionally, set up the name of the exported file through theFileNamemethod.Razor@(Html.Kendo().Editor() .Name("Editor") .Tools(tools => tools .ExportAs() ) .ExportAs(exportAs => exportAs .FileName("Export") .Proxy("Export", "Editor") ) ) -
Implement the action method in the corresponding controller.
C#using Telerik.Export.Core; ... [HttpPost] public ActionResult Export(EditorExportData data) { return EditorExport.Export(data); } ...To retrieve the Editor contents as an HTML string without downloading a file, call the client-side
value()method. The method returns the serialized HTML, including its tags:JS<script> var editor = $("#Editor").data("kendoEditor"); var html = editor.value(); console.log(html); // For example: <p><strong>Text</strong></p> </script>To download the contents as an HTML file, add
HTMLto theExportAsitems and configure the export proxy as shown above. The downloaded file contains HTML markup, which a browser renders as formatted content. To display the tags as text instead, use theencodedValue()method.
Importing Content from Files
-
Add the
Importtool.Razor@(Html.Kendo().Editor() .Name("Editor") .Tools(tools => tools .Import() ) ) -
Configure the
Importby using theProxyandAllowedExtensionsmethods.To send a file to the server, the
Importtool integrates the Telerik UI Upload HtmlHelper. You can configure it through the following exposed helper methods:Razor@(Html.Kendo().Editor() .Name("Editor") .Tools(tools => tools .Import() ) .Import(import => import .AllowedExtensions(new[] { "docx", "rtf", "html", "txt" }) .Proxy("Import","Editor") ) ) -
Implement the action method in the corresponding controller.
C#using Telerik.Export.Core; ... public ActionResult Import(HttpPostedFileBase file) { var settings = new EditorImportSettings(); string htmlResult; switch (Path.GetExtension(file.FileName)) { case ".docx": htmlResult = EditorImport.ToDocxImportResult(file, settings); break; case ".rtf": htmlResult = EditorImport.ToRtfImportResult(file, settings); break; default: htmlResult = EditorImport.GetTextContent(file); break; } return Json(new { html = htmlResult }); } ...
Changing Import and Export Settings
The Document Processing Library provides settings for the import and export which enables you to fine-tune the way the content is handled in the supported document types. The following example demonstrates how to use HtmlImportSettings so that you can process HTML images before they are exported to RadFlowDocument.
using Telerik.Export.Core;
using Telerik.Windows.Documents.Flow.FormatProviders.Html;
...
[HttpPost]
public ActionResult Export(EditorExportData data)
{
var settings = new EditorDocumentsSettings();
settings.HtmlImportSettings.LoadImageFromUri += HtmlImportSettings_LoadImageFromUri;
return EditorExport.Export(data, settings);
}
private void HtmlImportSettings_LoadImageFromUri(object sender, LoadImageFromUriEventArgs e)
{
var uri = e.Uri;
var absoluteUrl = uri.StartsWith("http://") || uri.StartsWith("www.");
if (!absoluteUrl)
{
var filePath = Server.MapPath(uri);
using (var fileStream = System.IO.File.OpenRead(filePath))
{
using (var memoryStream = new MemoryStream())
{
fileStream.CopyTo(memoryStream);
e.SetImageInfo(memoryStream.ToArray(), "png");
}
}
}
}
...
The following example demonstrates how to configure the import capabilities so that images are generated with inline base64 data in the HTML <img> tag. For more information on each setting that is supported by EditorImportSettings, refer to the documentation on HTML export settings.
using Telerik.Export.Core;
using Telerik.Windows.Documents.Flow.FormatProviders.Html;
...
public ActionResult Import(HttpPostedFileBase file)
{
var settings = new EditorImportSettings();
settings.ImagesImportMode = ImagesExportMode.Embedded;
string htmlResult = EditorImport.ToDocxImportResult(file, settings);
return Json(new { html = htmlResult });
}
...