Free Support Forum - aspose.com

Get X-Y position of Table cell v. 8.4.2.0

I tried adding an image to a table cell but with the only two options of PictureFillModeEx.Stretch or Tile tends distort the images.


As a result, I want to add an image where a specific table cell is located but the cell.OffsetX and cell.OffsetY methods are not accurate or I am unsure how to use them.

What is the proper method of getting the X,Y coordinates of a table cell?

private void AddStatusImage(PresentationEx presentation, SlideEx slide, TableEx table, CellEx cell, Status status)
{
ImageEx image = this.GetImage(presentation, status);

if(image!=null)
{
int id = slide.Shapes.AddPictureFrame(ShapeTypeEx.Rectangle,Convert.ToSingle(cell.OffsetX),Convert.ToSingle(cell.OffsetY),image.Width, image.Height, image);
PictureFrameEx picfram = (PictureFrameEx)slide.Shapes[id];

// Setting relative scale width and height
picfram.RelativeScaleHeight = 1.00f;
picfram.RelativeScaleWidth = 1.00f;
}

}

Hi Chris,


I have observed your comments. I request you to please share source presentation in which you want to add image.

Best Regards,


The source for this is large and abstracted. So, if I have a table and in that table I have a cell, what is the method for getting that cell's current X,Y position?

I tried something like so:
Convert.ToSingle(table.X - cell.OffsetX), Convert.ToSingle(table.Y - cell.OffsetY

Or would getting the X, Y of a cell require iteration of the table adding the individual offsets of rows + columns?

Hi Chris,


I have observed your comments. This link will help you to achieve your requirements. I hope you will find it helpful. Please share feedback with us if there is still an issue.

Best Regards,