利用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