Hi, in word document, there is one Table element, I dynamically added some rows to the table, because cell text maybe has multiple row, is it possible the table or all rows height?
Hi there,
Thanks for your inquiry.
The height of a table row is controlled using height and height rule
properties. These can be set differently for each row in the table which
allows for wide control over the height of each row. Please read
following documentation link for your kind reference.
http://www.aspose.com/docs/display/wordsnet/Specifying+Row+Heights
I suggest you please
encapsulate the table inside a bookmark and use following code example
to get the height of a table. Hope this helps you.
Document doc = new Document(MyDir + "in.docx");
LayoutCollector layoutCollector = new LayoutCollector(doc);
LayoutEnumerator layoutEnumerator = new LayoutEnumerator(doc);
foreach (BookmarkStart bStart in doc.GetChildNodes(NodeType.BookmarkStart, true))
{
if (!bStart.Bookmark.Name.StartsWith("bm"))
continue;
var renderObject = layoutCollector.GetEntity(bStart);
layoutEnumerator.Current = renderObject;
RectangleF location = layoutEnumerator.Rectangle;
renderObject = layoutCollector.GetEntity(bStart.Bookmark.BookmarkEnd);
layoutEnumerator.Current = renderObject;
RectangleF location2 = layoutEnumerator.Rectangle;
Console.WriteLine(location2.Y - location.Y);
}
The Aspose.Words.Layout namespace provides
classes that allow to access information such as on what page and where
on a page particular document elements are positioned, when the document
is formatted into pages.
LayoutEnumerator class allows you to
enumerates page layout entities of a document. You can use this class to
walk over the page layout model. Available properties are type,
geometry, text and page index where entity is rendered, as well as
overall structure and relationships. Use combination of GetEntity and
Current move to the entity which corresponds to a document node.
Please read about Aspose.Words.Layout namespace from here:
http://www.aspose.com/docs/display/wordsnet/Aspose.Words.Layout+namespace
Thanks for your response, I will try it.
Hi there,
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.
It works and solve my issue, thanks for your great help!!
Hi there,
Thanks for your feedback. It is nice to hear from you that your problem has been solved. Please let us know if you have any more queries.