Hi Paresh,
Thanks for your inquiry. Please use the following code example to set the image position as shown in first table.
Document doc = new Document(MyDir + "aspose_centre_picture_issue.doc");
Table table = (Table)doc.GetChild(NodeType.Table, 1, true);
Shape shape = (Shape)table.GetChild(NodeType.Shape, 0, true);
shape.WrapType
= WrapType.Square;
shape.Left
= 5;
shape.Top
= 5;
shape.RelativeHorizontalPosition
= RelativeHorizontalPosition.Column;
shape.RelativeVerticalPosition
= RelativeVerticalPosition.Paragraph;
doc.Save(MyDir + "Out.docx");
You can also set the image position in the middle of cell using following code example. Hope this helps you.
Document doc = new Document(MyDir + "aspose_centre_picture_issue.doc");
Table table = (Table)doc.GetChild(NodeType.Table, 1, true);
Shape shape = (Shape)table.GetChild(NodeType.Shape, 0, true);
shape.WrapType
= WrapType.Inline;
Cell cell = (Cell)shape.GetAncestor(NodeType.Cell);
cell.FirstParagraph.ParagraphFormat.ClearFormatting();
shape.ParentParagraph.ParagraphFormat.Alignment
= ParagraphAlignment.Center;
cell.CellFormat.ClearFormatting();
cell.CellFormat.LeftPadding
= 10;
cell.CellFormat.TopPadding
= 10;
cell.CellFormat.BottomPadding
= 10;
cell.CellFormat.RightPadding
= 10;
doc.Save(MyDir + "Out.docx");