private void btnHtmlCustomUri_Click(object sender, EventArgs e)
        {
            this.fileName = GetFileName("Hypertext Markup Language|*.html");
            string htmlText = String.Empty;

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }
            try
            {
                #region #exporthtml
                CustomUriProvider uriProvider = new CustomUriProvider(Path.GetDirectoryName(fileName));
                if (this.richEditControl.Document.Selection.Length > 0)
                {
                    DevExpress.XtraRichEdit.API.Native.DocumentRange selection = richEditControl.Document.Selection;
                    DevExpress.XtraRichEdit.API.Native.SubDocument   doc       = selection.BeginUpdateDocument();
                    htmlText = doc.GetHtmlText(selection, uriProvider);
                    selection.EndUpdateDocument(doc);
                }
                else
                {
                    htmlText = richEditControl.Document.GetHtmlText(richEditControl.Document.Range, uriProvider);
                }
                #endregion #exporthtml
                SaveFile(this.fileName, htmlText);
                OpenFile(this.fileName);
            }
            finally
            {
                this.fileName = String.Empty;
            }
        }
        private void btnMht_Click(object sender, EventArgs e)
        {
            this.fileName = GetFileName("Web Archive|*.mht");
            string mhtText = String.Empty;

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }
            try
            {
                #region #exportmht
                if (this.richEditControl.Document.Selection.Length > 0)
                {
                    DevExpress.XtraRichEdit.API.Native.DocumentRange selection = richEditControl.Document.Selection;
                    DevExpress.XtraRichEdit.API.Native.SubDocument   doc       = selection.BeginUpdateDocument();
                    mhtText = doc.GetMhtText(selection);
                    selection.EndUpdateDocument(doc);
                }
                else
                {
                    mhtText = richEditControl.Document.GetMhtText(richEditControl.Document.Range);
                }
                #endregion #exportmht
                SaveFile(this.fileName, mhtText);
                OpenFile(this.fileName);
            }
            finally
            {
                this.fileName = String.Empty;
            }
        }
        private void btnXml_Click(object sender, EventArgs e)
        {
            this.fileName = GetFileName("Microsoft Word XML Document|*.xml");
            string wordMLText = String.Empty;

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }
            try
            {
                #region #exportxml
                if (this.richEditControl.Document.Selection.Length > 0)
                {
                    DevExpress.XtraRichEdit.API.Native.DocumentRange selection = richEditControl.Document.Selection;
                    DevExpress.XtraRichEdit.API.Native.SubDocument   doc       = selection.BeginUpdateDocument();
                    wordMLText = doc.GetWordMLText(selection);
                    selection.EndUpdateDocument(doc);
                }
                else
                {
                    wordMLText = richEditControl.Document.GetWordMLText(richEditControl.Document.Range);
                }
                #endregion #exportxml
                SaveFile(this.fileName, wordMLText);
                OpenFile(this.fileName);
            }
            finally
            {
                this.fileName = String.Empty;
            }
        }
        private void btnRtf_Click(object sender, EventArgs e)
        {
            this.fileName = GetFileName("Rich Text Format|*.rtf");
            string rtfText = String.Empty;

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }
            try
            {
                #region #exportrtf
                if (this.richEditControl.Document.Selection.Length > 0)
                {
                    DevExpress.XtraRichEdit.API.Native.DocumentRange selection = richEditControl.Document.Selection;
                    DevExpress.XtraRichEdit.API.Native.SubDocument   doc       = selection.BeginUpdateDocument();
                    rtfText = doc.GetRtfText(selection);
                    selection.EndUpdateDocument(doc);
                }
                else
                {
                    rtfText = richEditControl.Document.GetRtfText(richEditControl.Document.Range);
                }
                #endregion #exportrtf
                SaveFile(this.fileName, rtfText);
                OpenFile(this.fileName);
            }
            finally
            {
                this.fileName = String.Empty;
            }
        }
        private void btnDocx_Click(object sender, EventArgs e)
        {
            this.fileName = GetFileName("Word 2007 Document|*.docx");
            byte[] bytes;

            if (String.IsNullOrEmpty(fileName))
            {
                return;
            }
            try
            {
                #region #exportdocx
                if (this.richEditControl.Document.Selection.Length > 0)
                {
                    DevExpress.XtraRichEdit.API.Native.DocumentRange selection = richEditControl.Document.Selection;
                    DevExpress.XtraRichEdit.API.Native.SubDocument   doc       = selection.BeginUpdateDocument();
                    bytes = doc.GetOpenXmlBytes(selection);
                    selection.EndUpdateDocument(doc);
                }
                else
                {
                    bytes = richEditControl.Document.GetOpenXmlBytes(richEditControl.Document.Range);
                }
                #endregion #exportdocx
                SaveFile(this.fileName, bytes);
                OpenFile(this.fileName);
            }
            finally
            {
                this.fileName = String.Empty;
            }
        }
        private void btnHtmlOptions_Click(object sender, EventArgs e)
        {
            #region #exporthtmloptions
            frmBrowser myBrowser = new frmBrowser();
            DevExpress.XtraRichEdit.Export.HtmlDocumentExporterOptions myExportOptions =
                new DevExpress.XtraRichEdit.Export.HtmlDocumentExporterOptions();
            myExportOptions.Encoding = System.Text.Encoding.Unicode;

            if (this.richEditControl.Document.Selection.Length > 0)
            {
                DevExpress.XtraRichEdit.API.Native.DocumentRange selection = richEditControl.Document.Selection;
                DevExpress.XtraRichEdit.API.Native.SubDocument   doc       = selection.BeginUpdateDocument();
                myBrowser.SetHtml(doc.GetHtmlText(selection, null, myExportOptions));
                selection.EndUpdateDocument(doc);
            }
            else
            {
                myBrowser.SetHtml(richEditControl.Document.GetHtmlText(richEditControl.Document.Range, null, myExportOptions));
            }

            myBrowser.Show();
        }