Skip to main content

DocumentImageSource Class

Contains static methods used to create an image from various sources.

Namespace: DevExpress.XtraRichEdit.API.Native

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

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

Declaration

[ComVisible(true)]
public abstract class DocumentImageSource

Remarks

The following image formats are available:

  • Bitmap (*.bmp, *.dib)
  • JPEG File Interchange Format (*.jpg, *.jpeg)
  • Portable Network Graphics (*.png)
  • Graphics Interchange Format (*.gif)
  • Tagged Image Format (*.tif, *.tiff)
  • Microsoft Enhanced Metafile (*.emf)
  • Windows Metafile (*.wmf)
  • Scalable Vector Graphics (*.svg)

Example: Create an Image from Different Sources

using DevExpress.BarCodes;
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 from a file.
    DocumentRange rangeFound = doc.FindAll("Visual Studio Magazine", SearchOptions.CaseSensitive)[0];
    DocumentPosition pos = doc.Paragraphs[doc.Paragraphs.Get(rangeFound.End).Index + 2].Range.Start;
    doc.Shapes.InsertPicture(pos, DocumentImageSource.FromFile("Pictures\\ReadersChoice.png"));

    // Insert an image from a stream.
    pos = doc.Paragraphs[4].Range.Start;
    string imageToInsert = "information.png";
    Assembly a = Assembly.GetExecutingAssembly();
    Stream imageStream = a.GetManifestResourceStream("InlinePictures.Resources." + imageToInsert);
    doc.Shapes.InsertPicture(pos, DocumentImageSource.FromStream(imageStream));

    // 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);
}

Inheritance

Object
DocumentImageSource
See Also