Skip to main content

DocumentImageSource.FromUri(String, IServiceContainer) Method

SECURITY NOTE

Downloading images passed as URLs to the FromUri method may create security issues. Review the following help topic and learn how to spot, analyze, and prohibit unwanted download requests:

Suppress Control Requests to Download Data from External URLs

Creates an image source object from the specified URI string.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v24.1.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

[ComVisible(false)]
public static DocumentImageSource FromUri(
    string uri,
    IServiceContainer serviceContainer
)

Parameters

Name Type Description
uri String

A string of characters identifying the resource in the Internet that can be interpreted as an image.

serviceContainer IServiceContainer

An object providing the IUriStreamService interface which allows you to get a data stream for a specified URI.

Returns

Type Description
DocumentImageSource

A DocumentImageSource object representing the image in the document.

Remarks

Use the RichEditControl or RichEditDocumentServer instance as the service container to get images for the specified URI or implement your own service provider.

The following example demonstrates how the FromUri method can be used to load an image by its URL.

using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer()) {
    wordProcessor.LoadDocument("Texts\\Pictures.docx");
    Document doc = wordProcessor.Document;
    // Insert an image using its URI.
    string imageUri = "http://i.gyazo.com/798a2ed48a3535c6c8add0ea7a4fc4e6.png";
    SubDocument docHeader = doc.Sections[0].BeginUpdateHeader();
    docHeader.Images.Append(DocumentImageSource.FromUri(imageUri, wordProcessor));
    doc.Sections[0].EndUpdateHeader(docHeader);
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the FromUri(String, IServiceContainer) method.

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