officefileapi-devexpress-dot-xtrarichedit-dot-export-dot-htmldocumentexporteroptions.md
Specifies whether images are embedded in an HTML document.
Namespace : DevExpress.XtraRichEdit.Export
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
[DefaultValue(false)]
public virtual bool EmbedImages { get; set; }
<DefaultValue(False)>
Public Overridable Property EmbedImages As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true to embed images in a page; otherwise, false.
|
You can access this nested property as listed below:
| Object Type | Path to EmbedImages |
|---|---|
| RichEditDocumentExportOptions |
.Html .EmbedImages
|
Use the EmbedImages property to specify whether images should be embedded into a page, or stored externally. Embedded images in the HTML document are stored in base64 encoding.
Note
There are situations when the EmbedImages setting is disregarded. The SubDocument.GetHtmlText method with unspecified IUriProvider instance (set to null ), Document.HtmlText and RichEditDocumentServer.HtmlText properties always return HTML string with embedded images.
The following code snippet uses 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 embedded images.
View Example: Retain the Original Image URI in an HTML Document
using DevExpress.Office.Services;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraRichEdit.Export;
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()
{
HtmlDocumentExporterOptions exportOptions = new 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 DevExpress.XtraRichEdit.Export
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 HtmlDocumentExporterOptions()
exportOptions.EmbedImages = embedImagesCheck.Checked
Dim sText As String = richEditControl1.Document.GetHtmlText(richEditControl1.Document.Range, New CustomUriProvider(), exportOptions)
memoEdit1.Text = sText
End Sub
using DevExpress.Office.Services;
using DevExpress.Office.Utils;
using System;
// ...
public class CustomUriProvider : IUriProvider
{
public string CreateCssUri(string rootUri, string styleText, string relativeUri)
{
return String.Empty;
}
public string CreateImageUri(string rootUri, OfficeImage image, string relativeUri)
{
return image.Uri;
}
}
Imports DevExpress.Office.Services
Imports DevExpress.Office.Utils
Imports System
' ...
Public Class CustomUriProvider
Implements IUriProvider
Public Function CreateCssUri(ByVal rootUri As String, ByVal styleText As String, ByVal relativeUri As String) As String Implements IUriProvider.CreateCssUri
Return String.Empty
End Function
Public Function CreateImageUri(ByVal rootUri As String, ByVal image As OfficeImage, ByVal relativeUri As String) As String Implements IUriProvider.CreateImageUri
Return image.Uri
End Function
End Class
The following code snippets (auto-collected from DevExpress Examples) contain references to the EmbedImages property.
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.
office-file-api-in-web-api-app/CS/BusinessObjects/Helpers.cs#L33
if (documentFormat == RichEditDocumentFormat.Html)
server.Options.Export.Html.EmbedImages = true;
if (encryptionSettings == null)
winforms-rich-text-editor-retain-original-image-uri-in-html-document/CS/Form1.cs#L30
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);
var resultStream = new MemoryStream();
wordProcessor.Options.Export.Html.EmbedImages = true;
wordProcessor.SaveDocument(resultStream, DevExpress.XtraRichEdit.DocumentFormat.Html);
how-to-customize-copy-and-paste-commands/CS/RichEditCustomCopyPaste/CustomCommands.cs#L46
exporterOptions.ExportRootTag = ExportRootTag.Body;
exporterOptions.EmbedImages = false; // To delegate handling into a CustomUriProvider
}
word-document-api-use-multiple-data-sources-for-mail-merge/CS/MailMergeSample/Default.aspx.cs#L66
}
documentServer.Options.Export.Html.EmbedImages = true;
mailMergeOptions.MergeMode = MergeMode.JoinTables;
winforms-rich-text-editor-retain-original-image-uri-in-html-document/VB/Form1.vb#L26
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)
how-to-customize-copy-and-paste-commands/VB/CustomCommands.vb#L47
exporterOptions.ExportRootTag = ExportRootTag.Body
exporterOptions.EmbedImages = False ' To delegate handling into a CustomUriProvider
End If
word-document-api-use-multiple-data-sources-for-mail-merge/VB/MailMergeSample/Default.aspx.vb#L54
documentServer.Options.Export.Html.EmbedImages = True
mailMergeOptions.MergeMode = MergeMode.JoinTables
See Also
HtmlDocumentExporterOptions Class