How to get the bounds (location) of a table inside Word document

My need is to know if a shape contains a table or not. As table is not considered as a child of the shape, i would like to get this information by comparing their bounds

This message was posted using Aspose.Live 2 Forum

Thank you for your inquiry.
If these table and shape are unrelated then it isn’t a good idea to analyze their bounds to check whether the table fits in the shape. This is quite complex and not reliable.
Please attach you document here and explain what you are going to do in more details. We’ll investigate your case and probably advise an easier solution.

Thank you for your answer. Nice to read that there is a easier solution. Please, find in attachment an explanation of my need.
For my knowledge, is there a way to get the table bounds?

Thank you for your explanation.
This is not what Aspose.Words is originally intended for. We cannot measure vertical size of a table as well as anything else because it’s a rendering task. But Aspose.Words doesn’t perform rendering when working with document model. But I tried two approaches which could be helpful. Nothing is impossible.

  1. You can place a table right inside an autoshape. In the attachment it’s the upper construction. Here I inserted inline box with rounded corners into the document, marked it as having text and placed the table inside. Advantage is that now shape is the parent of table. They are logically connected. Disadvantage is that you still cannot measure how much vertical space your table will occupy and inflate the shape to fit that size. It’s a rendering task and cannot be solved here.
  2. You can insert a table with one more row and one more column at every side, apply proper table borders and put arcs, a kind of autoshape, in the corner cells. This is the lower construction in the attachment. Note that arcs should be anchored to the table, not page or outer paragraphs. It’s difficult to place them precisely. MS Word has no aids to snap them and we have to do this manually. I turned view scale to 500% and spent some time to get this right. I believe you can make better. After you are finished with this beauty, as now you have something like rounded rectangle around the table, you can programmatically duplicate the second row several times to achieve required number of rows.

These two are only ideas. I can repeat that in MS Word and Aspose.Words there is no standard approach to achieve what you need.