Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

To insert an image into a section of your document, use one of the following methods. Each method inserts an image at the beginning or end of an Element. An Element object represents an editable region in a document, such as a section or paragraph. The document itself is an Element.

 

Insert an image specified by file name at the beginning of the element.

Code Block
InlineImage Element.InsertImageBefore(String fileName)

 

Insert an image specified by file name at the end of the element.

Code Block
InlineImage Element.InsertImageAfter(String fileName)

 

Insert an image contained in the specified stream at the beginning of the element.

Code Block
InlineImage Element.InsertImageBefore(System.IO.Stream stream)

 

Inserts the image contained in the specified stream at the end of the element.

Code Block
InlineImage Element.InsertImageAfter(System.IO.Stream stream)

 

Before adding an image to your file, you must create a content region in which to insert the image. Each editable region in a Word file is represented by an Element object, or an object that extends Element, such as a Document

Code Block
c#
c#

object.WordApplication wwapp = new WordApplication();
Document doc = wwapp.Create();

To insert an image, use one of the methods listed at the beginning of this section, for example:

Code Block

InlineImage img = doc.InsertImageAfter("C:\\sample.jpg");

...