我已将图片添加到Word Doc中为:
var app = new Word.Application();
DocForPrint = app.Documents.Add();
Range docRange = DocForPrint.Range();
Word.InlineShape picShape = docRange.InlineShapes.AddPicture(imgPath);
现在,我想像在Word编辑器中一样更改/设置其绝对大小
问题是我找不到它的属性,因为
picShape.Width = 50;
似乎是pxl大小。
你知道怎么做吗?
答案 0 :(得分:1)
由于Word是文字处理程序,因此它使用的许多度量单位都是 points -这是打印度量。幸运的是,Word应用程序还提供了点,像素,厘米和英寸的转换功能。
Word.Document DocForPrint = wdApp.Documents.Add();
Word.Range docRange = DocForPrint.Content;
Word.InlineShape picShape = docRange.InlineShapes.AddPicture(imgPath);
picShape.Width = wdApp.CentimetersToPoints(21.89f);
picShape.Height = wdApp.CentimetersToPoints(15.6f);