Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

ShapeCollection.InsertPicture(DocumentPosition, Image) Method

Inserts a picture in the document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v20.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core

Declaration

Shape InsertPicture(
    DocumentPosition pos,
    Image image
)

Parameters

Name Type Description
pos DocumentPosition

The position of the picture’s anchor.

image Image

The image to insert.

Returns

Type Description
Shape

The picture embedded in the document.

Remarks

The InsertPicture method positions a floating picture at the top-left corner of the page that contains the picture’s anchor. The TextWrapping property is set to InFrontOfText.

The Word Processing Document API and Rich Text Editors support the following image types:

  • 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)

The example below inserts a picture and specifies its horizontal alignment.

Document document = wordProcessor.Document;
document.AppendText("Line One\nLine Two\nLine Three");
Shape myPicture = document.Shapes.InsertPicture(document.CreatePosition(15),
    System.Drawing.Image.FromFile("Documents\\beverages.png"));
myPicture.HorizontalAlignment = ShapeHorizontalAlignment.Center;

The following code snippets (auto-collected from DevExpress Examples) contain references to the InsertPicture(DocumentPosition, Image) 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