Insert Image in Word Document in WPF

Word Image can make one document more interesting and impressive. Sometimes, image can be used explain contents. For example, if one document focuses on describing appearance one kind of birds, readers can learn more clearly with a bird picture.

Spire.Doc for WPF, a professional component to manipulate Word documents with WPF, enables users to insert image in Word with WPF. And this guide will show a method about how to insert image Word in WPF quickly.

Users can invoke paragraph.AppendPicture(image) method to insert image in Word directly. If you want to set image height/width to make picture display appropriately in document, you can use Height and Width property provided by DocPicture class which Spire.Doc for .NET offers. Below, there is the result after inserting image in Word.

Insert Word Image

Download and install Spire.Doc for WPF. Then, add a button in MainWindow. Double click this button and use the following code to insert image in Word.

Code Sample:

[C#]
          //Create Document
            Document document = new Document();
            Section section = document.AddSection();
            Paragraph Imageparagraph = section.AddParagraph();

            //Insert Image
            Image image = Image.FromFile(@"E:\work\Documents\Image\street.jpg");
            DocPicture picture =Imageparagraph.AppendPicture(image);

            //Set Image
            picture.Height = 360;
            picture.Width = 525;
[VB.NET]
        'Create Document
        Dim document As New Document()
        Dim section As Section = document.AddSection()
        Dim Imageparagraph As Paragraph = section.AddParagraph()

        'Insert Image
        Dim image As Image = image.FromFile("E:\work\Documents\Image\street.jpg")
        Dim picture As DocPicture = Imageparagraph.AppendPicture(image)

        'Set Image
        picture.Height = 360
        picture.Width = 525

Spire.Doc is a Microsoft Word component, which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF, .NET and Silverlight.