利用Aspose.word.dll 在生产的Word中插入图片到指定位置


添加引用

using Aspose.Words;
using Aspose.Words.Drawing;
using Aspose.Words.Rendering;

 

  Document doc = new Document(TempValue);//TempValue doc模板的路径


  DocumentBuilder builder = new DocumentBuilder(doc);

  Shape shape = new Shape(doc,ShapeType.Image);

  shape.ImageData.SetImage(Server.MapPath("Images/test.jpg"));

  shape.Width = 70;//设置宽和高
  shape.Height = 70;

  shape.WrapType = WrapType.None;
  shape.BehindText = true;

  //shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
  //shape.HorizontalAlignment = HorizontalAlignment.Center;
  //shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
  //shape.VerticalAlignment = VerticalAlignment.Center;
  //shape.HorizontalAlignment = HorizontalAlignment.Center;

  builder.MoveToBookmark("PO_MyImage");
  builder.InsertNode(shape);

  doc.Save("newword.doc",SaveFormat.Doc);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM