Character bounding box

Hi,

i need to know the bounding box of every single character on a rendered page.
I guess that during the rendering process these informations are calculated.

Is there a way to get these informations?

thanks and regards
Mark

Hi Mark,

Thanks for your inquiry. 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.

We suggest you please use LayoutCollector.GetEntity method to get an opaque position of the LayoutEnumerator which corresponds to the specified node. You can use returned value as an argument to Current given the document being enumerated and the document of the node are the same.

All text of the document is stored in runs of text. A run node may have single and multiple characters. If you need to navigate to a Run of text then you can insert bookmark right before it and then get the position of it. Please check the following code example.

Please also try EnumerateLayoutElements code example. Please get the code of “EnumerateLayoutElements” in Aspose.Words for .NET examples repository at GitHub. Hope this helps you.

Document doc = new Document(MyDir + "in.docx");
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator layoutEnumerator = new LayoutEnumerator(doc);
Bookmark bookmark = doc.Range.Bookmarks[0];
var renderObject = collector.GetEntity(bookmark.BookmarkStart);
layoutEnumerator.Current = renderObject;
Console.WriteLine(layoutEnumerator.Rectangle);