Free Support Forum -

Unable to get the RectangleF of a paragraph located in a cell of a table in slides



I am trying to get the RectangleF of a Paragraph in a cell of a table in slides, but when I get the paragraph located in the cell and I want to get the RectangleF using this code:
Rect = new RectangleF(paragraph.GetRect().X, paragraph.GetRect().Y, paragraph.GetRect().Width, paragraph.GetRect().Height);
I get the below exception:
Message = “Unable to cast object of type ‘Aspose.Slides.Cell’ to type ‘Aspose.Slides.GeometryShape’.”
I am using IParagraph interface to obtain the paragraph. Pls tell me what’s going on



Can you please share source file along with complete code snippet so that we may further investigate to help you out.


Thanks for your swift reply,
Unfortunately, I can’t upload a file of pptx so I uploaded an Image instead
here is a sample code:
var presentation = new Presentation(file);
List paragraphsRect = new List();
foreach (var slide in presentation.Slides)
foreach (var shape in slide.Shapes)
if (shape is ITable)
foreach (IColumn column in ((ITable)shape).Columns)
foreach (ICell cell in column)
foreach (IParagraph paragraph in cell.TextFrame.Paragraphs)
result_0.png (11.8 KB)



Can you please share source presentation file, This will help us to resolve issue as soon as possible. You can share source file via Dropbox as well.


@Adnan.Ahmad Okay, Here is the link



I have shared sample code with you. This will help you to achieve your requirements. Please share feedback with us if there is still an issue.

using (Presentation presentation = new Presentation(path+“Test.pptx”))
foreach (IShape shape in presentation.Slides[0].Shapes)
Table table = shape as Table;
if (table != null)
Cell tableCell = table.Rows[0][0] as Cell;
Console.WriteLine("Cell: "+ tableCell.TextFrame.Text);
RectangleF frameRect = new RectangleF(
(float)(table.X + tableCell.OffsetX),
(float)(table.Y + tableCell.OffsetY),
Console.WriteLine("Cell frame: " + frameRect);



@Adnan.Ahmad Thanks once again for your swift reply,
This is how to get the coordinates of the cell, I want to know if it is possible to get the paragraph and also the portion in the paragraph coordinates in that particular cell.



I like to inform that we dont have function for instant getting of paragraphs/potions coordinates. You have to calculate it by yourself. If there is still an issue than please share requirements we will investigate further on our end to help you out.


@Adnan.Ahmad Okay, thank you for your reply, One last question, is it possible to get the width of a portion in a paragraph?



I regret to share that at present the support for getting the size of Portion or Paragraph inside TextFrame is not available in API. An issue with ID SLIDESNET-40977 has been created in our issue tracking system to provide the requested support. We will share the good news with you as soon as the issue will be fixed.