Skip to main content
A newer version of this page is available. .

IUriProviderService Interface

Represents a service that calls the registered IUriProvider interface when required.

Namespace: DevExpress.Office.Services

Assembly: DevExpress.Office.v18.2.Core.dll

Declaration

[ComVisible(true)]
public interface IUriProviderService

Remarks

To be able to specify custom locations for exported images and styles, you should create a class that implements the IUriProvider interface and register it via the IUriProviderService.RegisterProvider method.

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E1726.

Example

This example demonstrates how to use the DocumentImage.Uri property to set the image’s src attribute when a document is saved in HTML format. You can switch on the HtmlDocumentExporterOptions.EmbedImages option to observe that the custom URI provider is idle for emdedded images.

Note

The complete sample project How to retain the original image URI in an HTML document is available in the DevExpress Examples repository.

using DevExpress.Office.Services;
using DevExpress.XtraRichEdit.API.Native;
using System;
// ...
        private void richEditControl1_DocumentLoaded(object sender, EventArgs e)
        {
            IUriProviderService service = richEditControl1.GetService<IUriProviderService>();
            if (service != null) {
                service.RegisterProvider(new CustomUriProvider());
            }
        }
        private void richEditControl1_ContentChanged(object sender, EventArgs e) {
            ReloadHtml();
        }

        private void ReloadHtml() {
            DevExpress.XtraRichEdit.Export.HtmlDocumentExporterOptions exportOptions = new DevExpress.XtraRichEdit.Export.HtmlDocumentExporterOptions();
            exportOptions.EmbedImages = embedImagesCheck.Checked;
            string sText = richEditControl1.Document.GetHtmlText(richEditControl1.Document.Range, new CustomUriProvider(), exportOptions);
            memoEdit1.Text = sText;
        }
Imports DevExpress.Office.Services
Imports DevExpress.XtraRichEdit.API.Native
Imports System
' ...
        Private Sub richEditControl1_DocumentLoaded(ByVal sender As Object, ByVal e As EventArgs) Handles richEditControl1.DocumentLoaded
            Dim service As IUriProviderService = richEditControl1.GetService(Of IUriProviderService)()
            If service IsNot Nothing Then
                service.RegisterProvider(New CustomUriProvider())
            End If
        End Sub

        Private Sub richEditControl1_ContentChanged(ByVal sender As Object, ByVal e As EventArgs)
            ReloadHtml()
        End Sub

        Private Sub ReloadHtml()
            Dim exportOptions As New DevExpress.XtraRichEdit.Export.HtmlDocumentExporterOptions()
            exportOptions.EmbedImages = embedImagesCheck.Checked
            Dim sText As String = richEditControl1.Document.GetHtmlText(richEditControl1.Document.Range, New CustomUriProvider(), exportOptions)
            memoEdit1.Text = sText
        End Sub

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

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