I have a problem while resizing an image during mail merge as showed here.
The problem is, in my template, which I attached, the cell which will contain the image spans multple rows, so the trick used to get row height cannot work since it returns the height of a single row and not the sum of all those.
How can I get the actual cell height then, in order to do proper resizing?
This does help, but only in this specific case, while I need a more generic algorithm.
Is there a way to know the “rowspan” of a cell using aspose.words? I do not see such method, but it could be just me not finding it.
public void FieldMerging(FieldMergingArgs args)
public void ImageFieldMerging(ImageFieldMergingArgs args)
DocumentBuilder builder = new DocumentBuilder(args.Document);
Shape img = builder.InsertImage(args.FieldValue.ToString());
Cell c = (Cell)builder.CurrentParagraph.GetAncestor(NodeType.Cell);
img.Width = c.CellFormat.Width;
img.Height = 0;
Table tbl = c.ParentRow.ParentTable;
for (int startRowIndex = tbl.Rows.IndexOf(c.ParentRow);
startRowIndex < tbl.Rows.Count;
Row row = tbl.Rows[startRowIndex];
foreach (Cell cell in row.Cells)
bool isVerticallyMerged = cell.CellFormat.VerticalMerge != CellMerge.None;
img.Height += row.RowFormat.Height;