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

后端 未结 2 1440
梦谈多话
梦谈多话 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:49

    Code, which I used to resize the picture successfully is:

    var shape = headerRange.InlineShapes.AddPicture(tempLogoPathName, true, true).ConvertToShape();
    shape.HeightRelative = 10f;
    shape.WidthRelative = 40f;
    

    Seems that convering to Shape is the solution. Previous set the different height directly in InLineShapes, produced an error. (I just edited a post and simplified the code, so it does not use 2nd dll library: Microsoft.Office.Core anymore)

提交回复
热议问题