Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Expand]Chart Control
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Collapse]HTML Editor
    Deployment of ASPxHtmlEditor
    Main Features
    Getting Started
    ASPxHtmlEditor Designer
   [Collapse]Concepts
    [Expand]View Modes
    [Expand]Get and Set HTML
    [Expand]Toolbars
    [Expand]Dialogs
     Context Menu
     Placeholders
    [Expand]Content Filtering and Validation
    [Expand]Layout
     Searching Content
     Client-Side Commands
     Keyboard Shortcuts
     Import and Export
     Support for SharePoint
   [Expand]Visual Elements
   [Expand]Examples
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Import and Export

ASPxHtmlEditor's contents can be imported and exported from/to various document formats. The supported formats include:

  • Rich Text (.rtf)
  • Office Open XML (.docx)
  • MIME HTML (.mht)
  • Open Document (.odt)
  • Plain Text (.txt)
  • Portable Document (.pdf). Available for export only.

Expanded Import

Import operations can only be initiated programmatically. Use a ASPxHtmlEditor.Import method overload for this purpose. With this method, you can import editor content from a file or stream and specify some additional settings.

The main import settings (available via the method's parameters) include:

  • filePath

    Specifies the path to a file (including the file name and extension, if any) whose content is to be imported into ASPxHtmlEditor. The file extension type is not taken into account if the import format is specified via format.

  • inputStream

    Specifies a stream from which the editor content is to be imported.

  • format

    Specifies the imported content format. Available values are listed within the HtmlEditorImportFormat enumeration. If the format is not specified, a file defined via filePath should have an extension matching supported formats; otherwise an exception occurs.

  • useInlineStyles

    Specifies whether or not document formatting styles (such as font settings, paragraph alignments, etc.) should be embedded into the editor's HTML content as in-line styles. If this parameter is not used or it is set to false, a specific separate css file will be automatically generated within a folder specified by the contentFolder parameter to store formatting styles used in the imported document.

  • contentFolder

    Specifies the path to a folder that should contain files required to represent the imported document's content. This folder is intended to contain images used within the document content and/or (if useInlineStyles is false or is not used) an automatically created css file that defines content style settings. If the contentFolder is not explicitly defined, content files will be placed in a default location specified by the ASPxHtmlEditorImageUploadSettings.UploadImageFolder property available via the editor's ASPxHtmlEditor.SettingsImageUpload property.

    Note

    Make sure that a target folder (to which content files will be saved) is granted the required access permissions (such as 'Write').

Expanded Example

The code below illustrates how to import the contents from a file, specifying either the file path and import format, or just a file path.

Expanded Export

Export of ASPxHtmlEditor contents can be initiated in the following manner.

Expanded Via a user interface.

You can allow end-users to export editor content via a specially designed toolbar item (ToolbarExportDropDownButton) that provides all the required functionality out of the box. All you have to do is add it to the editor's toolbar and customize output document formats available for end-users via the button's ToolbarExportDropDownButton.Items collection.

Expanded Programmatically on the server side.

Call an overload of the ASPxHtmlEditor.Export method to save the editor content to a stream or to the response.

The main export settings (available via the method's parameters) include:

  • fileName

    Specifies the exported file's name without an extension; the file extension will be added automatically based upon the specified format. If fileName is not defined, a default file name - the value of the control's ID property - is used.

  • outputStream

    Specifies a stream to which the editor content is to be exported.

  • format

    Specifies the exported document format. Available values are listed within the HtmlEditorExportFormat enumeration.

  • saveAsFile

    Specifies whether a client browser should save the exported document as a downloadable attachment or open it within the browser window (if the document format is allowed to be opening).

Example

This sample code demonstrates how ASPxHtmlEditor's contents can be programmatically exported, either to a file stream or to the response.

Expanded Programmatically on the client side.

To save the editor contents to a file, call the ASPxClientHtmlEditor.ExecuteCommand method with the EXPORT_COMMAND commandName parameter.

The parameter event setting specifies the format to export file. The available setting values are listed below.

  • Rtf - to save a content to Rich Text Format (.rtf)
  • Mht - to save a content to MIME HTML (.mht)
  • Odt - to save a content to Open Document (.odt)
  • Docx - to save a content to Office Open XML (.docx)
  • Txt - to save a content to Plain Text (.txt)
  • Pdf - to save a content to Portable Document (.pdf)

The addToUndoHistory event parameter is not in effect for the EXPORT_COMMAND command.

Example

This code sample demonstrates how ASPxHtmlEditor's contents can be programmatically exported using the client-side ExecuteCommand method.

Note

You can specify style settings that will be applied to an exported document by using the ASPxHtmlEditor.StylesDocument property.

How would you rate this topic?​​​​​​​