為什么無法將圖片導出到word,下為代碼
發表于2019-05-10
回復:0
查看:2657 |
string tmppath = Server.MapPath("~/image.doc");
Document doc = new Document(tmppath); //載入模板
#region 圖片
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = new Shape(doc, ShapeType.Image);
shape.ImageData.SetImage(Server.MapPath("~/Images/0.jpg"));
shape.Width = 70;
shape.Height = 70;
shape.HorizontalAlignment = HorizontalAlignment.Right; //靠右對齊
builder.MoveToBookmark("image");
builder.InsertNode(shape);
Bookmark myname = doc.Range.Bookmarks["image"];
myname.Text = "";
doc.Range.Bookmarks["image"].Remove();
doc.Save("demo.doc", SaveFormat.Doc, SaveType.OpenInWord, Response);
#endregion
登錄 慧都網發表評論