Paragraph/Image/Table Size

Hello,

I’m currently trying the API and I just want to know if there is a possibility with ASPOSE Words to get easily paragraph size ? and if there are same possibilites for image and table.

If someone knows how to find these information,
please inform me.

Best regards

Hi
Thank you for your interest in Aspose.Words.
You can get size of shape using Shape.Width and Shape.Height properties respectively. Please follow the link to learn more:
https://reference.aspose.com/words/net/aspose.words.drawing/shapebase/
Unfortunately, there are no Width and Height properties for Table node. However, you can calculate this value using Row.Format.Height and Cellformat.Width. For example see the following code:

// Open document
Document doc = new Document(@"Test107\in.doc");
// Get table from the docuent
Table tab = doc.FirstSection.Body.Tables[0];
// Calculate height of table
double height = 0;
// Loop through all rows in the table 
// NOTE: this value will be calculated only in case if 
// row.RowFormat.HeightRule != HeightRule.Auto
foreach (Row row in tab.Rows)
{
    height += row.RowFormat.Height;
}
// Use the same technique to calculate width of the table
double width = 0;
foreach (Cell cell in tab.FirstRow.Cells)
{
    width += cell.CellFormat.Width;
}
Console.Write(string.Format("Height of the table = {0} \r\nWidth of the table = {1}", height, width));

There is no way to calculate size of Paragraph using Aspose.Words. I think the following blog could answer some of your questions:
https://blog.aspose.com/2008/12/01/where-on-a-page-is-my-paragraph
In addition, could you tell me why you need this information?
Please let me know in case of any issues, I will be glad to help you.
Best regards.

In fact, I need to know these information to create automatically layout for a document without any user intervention.

But I have no way to determine the size of a paragraph, so It’s a little bit difficult to create layout without any size information.

Thanks for your response,

Hi

MS Word documents are flow documents and do not contain information about how the document is laid out. If you really need this feature, you can leave your comments and suggestions in the blog I pointed to in my previous answer. And we will consider the ability to add such functionality in the future.
However, I think you can build the document without this information. For example, you can use templates created using MS Word and then fill them with data.
Best regards.