如何在 office interop word c# 中的 2 张图片之间添加 space?

How to Add space between 2 pictures in office interop word c#?

我正在尝试添加两张图片,无论我做什么,它们都会放在一起 那么如何将这两张图片精确地添加到 under 之间 specified space

  //first picture

      wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
            string imagename = "C:\Users\a_shi\Desktop\Man\madarek\man3.jpg";
            InlineShape pictureShape = wrdRng.InlineShapes.AddPicture(imagename);
            pictureShape.Width = 150;
            pictureShape.Height = 150;
            Word.Shape shape = pictureShape.ConvertToShape();
            shape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;
            shape.Left = (float)Word.WdShapePosition.wdShapeCenter;
            shape.Top = (float)Word.WdShapePosition.wdShapeTop;
//what ive tried so far
            wrdRng.InsertParagraphAfter();
            wrdRng.InsertAfter("\v");

//second picture

    wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                string pa = "C:\Users\a_shi\Desktop\some stuff\wow.jpg";
                InlineShape pictureShape = wrdRng.InlineShapes.AddPicture(pa);
                pictureShape.Width = 100;
                pictureShape.Height = 150;
                Word.Shape shape1 = pictureShape.ConvertToShape();
                shape1.WrapFormat.Type = Word.WdWrapType.wdWrapSquare;
                shape1.Left = (float)Word.WdShapePosition.wdShapeCenter;
              shape1.Top = (float)Word.WdShapePosition.wdShapeTop

如何在office interop word中的任何元素后添加某些space(空行)?

当没有人可以帮助您时...自助!这就是我要做的:

假设您想在 office interop word 的 2 个元素之间添加 space,只需按照以下 3 个步骤操作即可:

1)定义一个新的Range并将其设置为文档结尾:

object newrng1 = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;

2)在我们刚刚定义的范围内添加一个新的段落。 (即使没有内容!)我们这样做是为了使用 ParagraphFormat 属性.

Word.Paragraph oPara = oDoc.Content.Paragraphs.Add(ref newrng1);

3)最后加上想要的space,注意LineSpacing属性只接受float。

 oPara.Range.ParagraphFormat.LineSpacing = 20.0f;