We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Get the Bounding Box of OfficeMath using Java

I’m trying to get the layout information for OfficeMath nodes using the LayoutCollector and LayoutEnumerator classes. This works for regular runs, paragraphs etc, but for most (but not all) OfficeMath nodes it fails. Specifically, in the example code below, the call to collector.getEntity(node) returns null.

    OfficeMath node = (OfficeMath) doc.getChildNodes(NodeType.OFFICE_MATH, true).get(0);

    LayoutCollector collector = new LayoutCollector(doc);
    Object entity = collector.getEntity(node);

    LayoutEnumerator enumerator = new LayoutEnumerator(doc);

Attaching simplest example document I could create which exhibits the problem. Using v21.8 of Aspose Words.

office_math_example.docx (12.9 KB)


We have logged this problem in our issue tracking system as WORDSNET-22673. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


We have closed this issue (WORDSNET-22673) as ‘Not a Bug’. Please note that the top level node is not processed for inline OfficeMath. For floating OfficeMath only top level node is processed. This is by design.

Thanks, but I’m not sure I understand your response. In my example document and code, how can I get the bounding box for the math content?


You can insert the Bookmark into OfficeMath and get the position of Bookmark using layout APIs. Hope this helps you.