C#: Online Guide
How To: Word SDK
Insert Image
  |  
Home ›› XDoc.Word ›› C# Word: Insert Image

C# Word - Insert Image to Word Page in C#.NET


How to Insert Image to Word Page in C# Project




Overview



RasterEdge XDoc.Word Library provides some methods for developers to insert image to Word pages. But if you want to insert various types of images, you may need to add the reference RasterEdge.XImage.Raster.dll into your project. If not, you can only add bitmap to Word page(s).



Add Image to Word Page Using C#



Add references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.Imaging.Basic.Codec.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Word;


  using RasterEdge.Imaging.Raster.Core;


It's a demo code for adding image to word page using C#.




DOCXDocument docx = new DOCXDocument(@"C:\1.docx");
BasePage page = docx.GetPage(0);
REImage image = new REImage(@"C:\logo2.jpg");
page.AddImage(image, new Point(100, 100));
docx.Save(@"C:\1image.docx");