在中插入图片,可以使用类似下面的代码。
using Aspose.Words;
using Aspose.Words.Tables;
using Aspose.Words.Rendering;
using Aspose.Words.Drawing;
Document doc = new Document(tmppath);
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = new Shape(doc, ShapeType.Image);
shape.ImageData.SetImage(Server.MapPath("~/WebPic/dzwebs.jpg"));
shape.Width = 70;
shape.Height = 70;
shape.HorizontalAlignment = HorizontalAlignment.Right; //靠右对齐
doc.Save("文件名称.doc", SaveFormat.Doc, SaveType.OpenInWord, Response);
知识拓展:
shape.ImageData.SetImage(…)加载图片的方法一共有四个重载,参数分别为:图片路径、字节、流、Image对象。