Skip to main content

RichEditControl.BeforeExport Event

Occurs before the document is saved (exported to a certain format).

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v24.2.dll

Declaration

public event BeforeExportEventHandler BeforeExport

Event Data

The BeforeExport event's data class is BeforeExportEventArgs. The following properties provide information specific to this event:

Property Description
CustomProperties Provides access to the document’s custom properties.
DocumentFormat Gets the format of the document being exported or saved.
Options Provides access to the exporter options.

Remarks

The BeforeExport event enables you to adjust the exporter options as required.

The BeforeExport event occurs after the RichEditControl.SaveDocument or RichEditControl.SaveDocumentAs method call.

You can check the Document.RequiredExportCapabilities to be sure that the chosen export format supports them.

The code sample below shows how specify export options for different formats in the RichEditControl.BeforeExport event handler.

private void RichEditControl_BeforeExport(object sender, BeforeExportEventArgs e)
{
    if (e.DocumentFormat == DocumentFormat.PlainText)
    {
        //Include document fields in the exported plain text:
        PlainTextDocumentExporterOptions plainTextOptions = e.Options as PlainTextDocumentExporterOptions;
        plainTextOptions.ExportHiddenText = true;
        plainTextOptions.FieldCodeEndMarker = ">";
        plainTextOptions.FieldCodeStartMarker = "[<";
        plainTextOptions.FieldResultEndMarker = "]";
    }

    if (e.DocumentFormat == DocumentFormat.OpenXml)
    {
        //Specify what DOCX document properties to export:
        OpenXmlDocumentExporterOptions docxOptions = e.Options as OpenXmlDocumentExporterOptions;
        docxOptions.ExportedDocumentProperties = DocumentPropertyNames.Title | DocumentPropertyNames.LastModifiedBy | DocumentPropertyNames.Modified;
    }

    if (e.DocumentFormat == DocumentFormat.Html)
    {
        //Specify HTML export options:
        HtmlDocumentExporterOptions htmlOptions = e.Options as HtmlDocumentExporterOptions;
        htmlOptions.EmbedImages = true;
        htmlOptions.CssPropertiesExportType = CssPropertiesExportType.Style;
        htmlOptions.UseFontSubstitution = false;
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the BeforeExport event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also