Dear Sir or Madam,
How can I calculate height of a node in a document? Eg. paragraph, table, row?
Regards,
Alex
Dear Sir or Madam,
How can I calculate height of a node in a document? Eg. paragraph, table, row?
Regards,
Alex
Thanks for your inquiry. You can get the paragraph’s height using following code example.
Document doc = new Document(MyDir + "in.docx");
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
Paragraph paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);
enumerator.Current = collector.GetEntity(paragraph);
Console.WriteLine(enumerator.Rectangle.Height);
The height of a table row/cell is controlled using height and height rule properties. Please refer to the following article for more detail.
Specifying Row Heights
If you want to calculate table’s height using Aspose.Words.Layout API, we suggest you following solution.
Please note that LayoutCollector.GetEntity method returns an opaque position of the LayoutEnumerator which corresponds to the specified node. This method works for only Paragraph nodes, as well as indivisible inline nodes, e.g. BookmarkStart or Shape. It doesn’t work for Run, CellRow or Table nodes, and nodes within header/footer.