Hi,
Thanks - that worked quite well and the output is as expected!
There is another place in our document where we do the same thing - however the shapes need to be inserted into a cell in a table. But the shape seems to appear off (see attached screen shot).
We have written the code similar to this:
var doc = new Document();
var builder = new DocumentBuilder(doc);
var table = builder.StartTable();
builder.InsertCell();
builder.EndRow();
builder.EndTable();
var tableIndex = builder.CurrentSection.Body.Tables.IndexOf(table);
builder.MoveToCell(tableIndex, 0, 0, 0);
builder.Write("cell ");
var bookmarkName = Guid.NewGuid().ToString();
builder.StartBookmark(bookmarkName);
builder.EndBookmark(bookmarkName);
Bookmark bm = doc.Range.Bookmarks[bookmarkName];
builder.MoveTo(bm.BookmarkEnd);
var shapeSize = 10;
var shape = new Shape(doc, ShapeType.Rectangle)
{
Width = shapeSize,
Height = shapeSize,
WrapType = WrapType.None,
FillColor = Color.FromArgb(0, 44, 119),
RelativeHorizontalPosition = RelativeHorizontalPosition.Page,
RelativeVerticalPosition = RelativeVerticalPosition.Page
};
builder.InsertNode(shape);
LayoutCollector lc = new LayoutCollector(doc);
LayoutEnumerator le = new LayoutEnumerator(doc);
object bmPosition = lc.GetEntity(bm.BookmarkEnd);
le.Current = bmPosition;
shape.Left = le.Rectangle.Left;
shape.Top = le.Rectangle.Y - le.Rectangle.Height / 4;
doc.Save("test.doc");
Thanks!