我想添加两张图片,无论我怎么做,它们都会被放在一起那么如何在下添加这两张图片呢?以指定的空间在之间?
//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互操作字的任何元素之后添加一定的空格(空行)?
当没有人帮助你的时候…帮助自己! 这就是我要做的:
所以假设你想在office互操作字的两个元素之间添加空格,只要按照下面的3个步骤做,你就会做得很好:
1)定义一个新的范围并将其设置为doc: 的末尾object newrng1 = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
2)在我们刚刚定义的范围中添加一个新的段落。(即使没有内容!)我们使用段落格式属性。
Word.Paragraph oPara = oDoc.Content.Paragraphs.Add(ref newrng1);
3)最后添加所需的空间,注意LineSpacing属性只接受浮点数
oPara.Range.ParagraphFormat.LineSpacing = 20.0f;