How to change the size of a picture after inserting it into a word document

后端 未结 2 1434
梦谈多话
梦谈多话 2020-12-18 03:20

I\'m adding a picture to a word document at a certain bookmark. However, the picture is too big and is forcing text off the page, so I need to be able to change the size of

2条回答
  •  离开以前
    2020-12-18 03:43

    When you insert the image, it should return you an InlineShape, which you can modify:

    Word.Application app = new Word.Application();
    var doc = app.Documents.Open(@"C:\Users\SomeUserName\Desktop\Doc1.docx");
    
    var shape = doc.Bookmarks["PicHere"].Range.InlineShapes.AddPicture(@"C:\Users\SomePicture\Pictures\1234.JPG", false, true);
    shape.Width = 150;
    shape.Height = 150;
    app.Visible = true;
    

提交回复
热议问题